JVM 与运行机制


一、JVM、JDK、JRE 的关系

1.1 三者关系图

<mxfile>
  <diagram id="jdk-jre-jvm-structure" name="JDK 结构图">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="800" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="680" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;fontStyle=1;fontColor=#1e40af;" value="JDK" vertex="1">
          <mxGeometry height="40" width="100" x="400" y="45" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#3b82f6;fontStyle=2;" value="Java Development Kit" vertex="1">
          <mxGeometry height="25" width="200" x="350" y="80" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="Java 开发工具包" vertex="1">
          <mxGeometry height="25" width="160" x="370" y="100" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="420" width="760" x="70" y="135" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#166534;" value="JRE" vertex="1">
          <mxGeometry height="35" width="100" x="400" y="145" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#22c55e;fontStyle=2;" value="Java Runtime Environment" vertex="1">
          <mxGeometry height="20" width="220" x="340" y="175" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="Java 运行时环境" vertex="1">
          <mxGeometry height="20" width="150" x="375" y="192" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="230" width="700" x="100" y="220" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;fontStyle=1;fontColor=#b45309;" value="JVM" vertex="1">
          <mxGeometry height="30" width="100" x="400" y="228" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#f59e0b;fontStyle=2;" value="Java Virtual Machine" vertex="1">
          <mxGeometry height="18" width="190" x="355" y="255" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#b45309;" value="Java 虚拟机" vertex="1">
          <mxGeometry height="18" width="120" x="390" y="270" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d97706;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="130" width="160" x="120" y="300" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="类加载器" vertex="1">
          <mxGeometry height="30" width="120" x="140" y="310" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;fontStyle=2;" value="ClassLoader" vertex="1">
          <mxGeometry height="20" width="120" x="140" y="345" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#92400e;" value="Bootstrap&#xa;Extension&#xa;Application" vertex="1">
          <mxGeometry height="50" width="120" x="140" y="370" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d97706;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="130" width="160" x="300" y="300" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="执行引擎" vertex="1">
          <mxGeometry height="30" width="120" x="320" y="310" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;fontStyle=2;" value="Execution Engine" vertex="1">
          <mxGeometry height="20" width="120" x="320" y="345" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#92400e;" value="解释器&#xa;JIT 编译器&#xa;GC 垃圾回收" vertex="1">
          <mxGeometry height="50" width="120" x="320" y="370" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d97706;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="130" width="300" x="480" y="300" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="运行时数据区" vertex="1">
          <mxGeometry height="30" width="120" x="570" y="310" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;fontStyle=2;" value="Runtime Data Areas" vertex="1">
          <mxGeometry height="20" width="120" x="570" y="345" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;fontSize=10;fontColor=#92400e;" value="堆 Heap" vertex="1">
          <mxGeometry height="40" width="60" x="495" y="375" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;fontSize=10;fontColor=#92400e;" value="栈 Stack" vertex="1">
          <mxGeometry height="40" width="60" x="565" y="375" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;fontSize=10;fontColor=#92400e;" value="方法区" vertex="1">
          <mxGeometry height="40" width="60" x="635" y="375" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;fontSize=10;fontColor=#92400e;" value="PC" vertex="1">
          <mxGeometry height="40" width="55" x="705" y="375" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="75" width="700" x="100" y="465" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="核心类库 Core Libraries" vertex="1">
          <mxGeometry height="28" width="220" x="340" y="472" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.lang" vertex="1">
          <mxGeometry height="26" width="75" x="115" y="505" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.util" vertex="1">
          <mxGeometry height="26" width="75" x="200" y="505" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.io" vertex="1">
          <mxGeometry height="26" width="75" x="285" y="505" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.net" vertex="1">
          <mxGeometry height="26" width="75" x="370" y="505" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.sql" vertex="1">
          <mxGeometry height="26" width="75" x="455" y="505" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.nio" vertex="1">
          <mxGeometry height="26" width="75" x="540" y="505" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="java.time" vertex="1">
          <mxGeometry height="26" width="75" x="625" y="505" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;fontSize=11;fontColor=#166534;fontStyle=1;" value="..." vertex="1">
          <mxGeometry height="26" width="40" x="710" y="505" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="90" width="760" x="70" y="570" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="开发工具 Dev Tools" vertex="1">
          <mxGeometry height="28" width="190" x="355" y="578" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="javac&#xa;编译器" vertex="1">
          <mxGeometry height="35" width="80" x="90" y="615" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="java&#xa;启动器" vertex="1">
          <mxGeometry height="35" width="80" x="185" y="615" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="jdb&#xa;调试器" vertex="1">
          <mxGeometry height="35" width="80" x="280" y="615" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="javadoc&#xa;文档生成" vertex="1">
          <mxGeometry height="35" width="80" x="375" y="615" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="jar&#xa;打包工具" vertex="1">
          <mxGeometry height="35" width="80" x="470" y="615" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="jlink&#xa;镜像工具" vertex="1">
          <mxGeometry height="35" width="80" x="565" y="615" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="jshell&#xa;交互式" vertex="1">
          <mxGeometry height="35" width="80" x="660" y="615" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;fontSize=11;fontColor=#1e40af;fontStyle=1;" value="..." vertex="1">
          <mxGeometry height="35" width="50" x="755" y="615" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f1f5f9;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="820" x="40" y="725" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK = JRE + 开发工具" vertex="1">
          <mxGeometry height="30" width="200" x="100" y="737" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JRE = JVM + 核心类库" vertex="1">
          <mxGeometry height="30" width="200" x="350" y="737" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#64748b;" value="📐 公式" vertex="1">
          <mxGeometry height="30" width="80" x="600" y="737" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

1.2 各组件详解

JVM(Java Virtual Machine)

<mxfile>
  <diagram id="jvm-core-responsibilities" name="JVM 核心职责">
    <mxGraphModel dx="900" dy="700" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="40" y="30" width="820" height="620" as="geometry" />
        </mxCell>
        <mxCell id="3" value="JVM 核心职责" style="text;html=1;strokeColor=none;fillColor=#1e40af;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="40" y="30" width="820" height="60" as="geometry" />
        </mxCell>
        <mxCell id="4" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="110" width="760" height="150" as="geometry" />
        </mxCell>
        <mxCell id="5" value="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#2563eb;fontColor=#ffffff;fontSize=18;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="125" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="6" value="加载字节码" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="140" y="130" width="150" height="35" as="geometry" />
        </mxCell>
        <mxCell id="7" value="将 .class 文件加载到 JVM 内存中" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="300" y="135" width="250" height="25" as="geometry" />
        </mxCell>
        <mxCell id="8" value=".class" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="120" y="185" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="9" value="字节码文件" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="130" y="235" width="100" height="20" as="geometry" />
        </mxCell>
        <mxCell id="10" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#3b82f6;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" edge="1" parent="1" source="8" target="11">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="11" value="类加载器" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#2563eb;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="340" y="185" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="12" value="ClassLoader" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="350" y="235" width="100" height="20" as="geometry" />
        </mxCell>
        <mxCell id="13" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#3b82f6;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" edge="1" parent="1" source="11" target="14">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="14" value="内存" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="560" y="185" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="15" value="Runtime Memory" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="560" y="235" width="120" height="20" as="geometry" />
        </mxCell>
        <mxCell id="16" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="700" y="195" width="35" height="35" as="geometry" />
        </mxCell>
        <mxCell id="17" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="280" width="760" height="150" as="geometry" />
        </mxCell>
        <mxCell id="18" value="2" style="ellipse;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;fontColor=#ffffff;fontSize=18;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="295" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="19" value="验证与执行" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#166534;" vertex="1" parent="1">
          <mxGeometry x="140" y="300" width="150" height="35" as="geometry" />
        </mxCell>
        <mxCell id="20" value="校验字节码安全性并执行程序" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#22c55e;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="300" y="305" width="250" height="25" as="geometry" />
        </mxCell>
        <mxCell id="21" value="字节码" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#166534;" vertex="1" parent="1">
          <mxGeometry x="120" y="355" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="22" value="Bytecode" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="130" y="405" width="100" height="20" as="geometry" />
        </mxCell>
        <mxCell id="23" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#22c55e;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" edge="1" parent="1" source="21" target="24">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="24" value="校验器" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="340" y="355" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="25" value="Verifier" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="350" y="405" width="100" height="20" as="geometry" />
        </mxCell>
        <mxCell id="26" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#22c55e;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" edge="1" parent="1" source="24" target="27">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="27" value="执行引擎" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#166534;" vertex="1" parent="1">
          <mxGeometry x="560" y="355" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="28" value="Execution Engine" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="555" y="405" width="130" height="20" as="geometry" />
        </mxCell>
        <mxCell id="29" value="⚡" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="700" y="365" width="35" height="35" as="geometry" />
        </mxCell>
        <mxCell id="30" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="450" width="760" height="150" as="geometry" />
        </mxCell>
        <mxCell id="31" value="3" style="ellipse;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#d97706;fontColor=#ffffff;fontSize=18;fontStyle=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="465" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="32" value="内存管理" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="140" y="470" width="150" height="35" as="geometry" />
        </mxCell>
        <mxCell id="33" value="自动分配和回收内存资源" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#f59e0b;fontStyle=2;" vertex="1" parent="1">
          <mxGeometry x="300" y="475" width="250" height="25" as="geometry" />
        </mxCell>
        <mxCell id="34" value="对象分配" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f59e0b;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="120" y="525" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="35" value="Object Allocation" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="120" y="575" width="120" height="20" as="geometry" />
        </mxCell>
        <mxCell id="36" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#f59e0b;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" edge="1" parent="1" source="34" target="37">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="37" value="GC" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#d97706;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="340" y="525" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="38" value="Garbage Collector" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="340" y="575" width="120" height="20" as="geometry" />
        </mxCell>
        <mxCell id="39" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#f59e0b;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" edge="1" parent="1" source="37" target="40">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="40" value="内存回收" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f59e0b;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="560" y="525" width="120" height="55" as="geometry" />
        </mxCell>
        <mxCell id="41" value="Memory Reclaim" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" vertex="1" parent="1">
          <mxGeometry x="560" y="575" width="120" height="20" as="geometry" />
        </mxCell>
        <mxCell id="42" value="♻️" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="700" y="535" width="35" height="35" as="geometry" />
        </mxCell>
        <mxCell id="43" value="🔄" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" vertex="1" parent="1">
          <mxGeometry x="755" y="295" width="40" height="40" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
JVM 的多语言支持:
<mxfile>
  <diagram id="jvm-language-ecosystem" name="JVM 语言生态">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="750" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="680" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=26;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JVM 语言生态" vertex="1">
          <mxGeometry height="60" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#6366f1;" value="🌐 多语言支持" vertex="1">
          <mxGeometry height="30" width="200" x="350" y="105" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="130" x="80" y="145" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Java" vertex="1">
          <mxGeometry height="40" width="100" x="95" y="160" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="☕ 经典主流" vertex="1">
          <mxGeometry height="25" width="100" x="95" y="205" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="130" x="230" y="145" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Kotlin" vertex="1">
          <mxGeometry height="40" width="100" x="245" y="160" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#4f46e5;" value="📱 Android 首选" vertex="1">
          <mxGeometry height="25" width="100" x="245" y="205" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="130" x="385" y="145" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Scala" vertex="1">
          <mxGeometry height="40" width="100" x="400" y="160" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#db2777;" value="⚡ 函数式编程" vertex="1">
          <mxGeometry height="25" width="100" x="400" y="205" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="130" x="530" y="145" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Groovy" vertex="1">
          <mxGeometry height="40" width="100" x="545" y="160" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#16a34a;" value="🔧 脚本 &amp; DSL" vertex="1">
          <mxGeometry height="25" width="100" x="545" y="205" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f1f5f9;strokeColor=#94a3b8;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="130" x="680" y="145" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#64748b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Clojure" vertex="1">
          <mxGeometry height="35" width="100" x="695" y="155" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;fontStyle=2;" value="JRuby / Jython" vertex="1">
          <mxGeometry height="20" width="100" x="695" y="195" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#64748b;fontStyle=1;" value="..." vertex="1">
          <mxGeometry height="25" width="50" x="720" y="215" as="geometry" />
        </mxCell>
        <mxCell id="21" edge="1" parent="1" source="5" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#f59e0b;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" target="30">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="145" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="22" edge="1" parent="1" source="8" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#6366f1;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" target="30">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="295" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="23" edge="1" parent="1" source="11" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#ec4899;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" target="30">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="445" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="24" edge="1" parent="1" source="14" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#22c55e;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" target="30">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="595" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="25" edge="1" parent="1" source="17" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#64748b;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;" target="30">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="745" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#64748b;fontStyle=1;" value="编译" vertex="1">
          <mxGeometry height="20" width="40" x="155" y="260" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#64748b;fontStyle=1;" value="编译" vertex="1">
          <mxGeometry height="20" width="40" x="305" y="260" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#64748b;fontStyle=1;" value="编译" vertex="1">
          <mxGeometry height="20" width="40" x="455" y="260" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#64748b;fontStyle=1;" value="编译" vertex="1">
          <mxGeometry height="20" width="40" x="605" y="260" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="120" width="700" x="100" y="320" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=22;fontStyle=1;fontColor=#ffffff;rounded=1;" value=".class 字节码" vertex="1">
          <mxGeometry height="45" width="260" x="320" y="340" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#1e40af;fontStyle=2;" value="统一的中间格式 · Unified Intermediate Format" vertex="1">
          <mxGeometry height="25" width="360" x="270" y="395" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="📄" vertex="1">
          <mxGeometry height="50" width="50" x="150" y="345" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="📄" vertex="1">
          <mxGeometry height="50" width="50" x="700" y="345" as="geometry" />
        </mxCell>
        <mxCell id="35" edge="1" parent="1" source="30" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#3b82f6;strokeWidth=4;endArrow=blockThin;endFill=1;endSize=10;" target="38">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="450" y="510" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#3b82f6;fontStyle=1;" value="加载 &amp; 执行" vertex="1">
          <mxGeometry height="25" width="100" x="470" y="455" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="140" width="700" x="100" y="500" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=28;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JVM" vertex="1">
          <mxGeometry height="50" width="160" x="370" y="520" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#b45309;fontStyle=2;" value="Java Virtual Machine" vertex="1">
          <mxGeometry height="25" width="220" x="340" y="575" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="统一的执行环境 · Unified Runtime Environment" vertex="1">
          <mxGeometry height="25" width="340" x="280" y="600" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=32;" value="⚙️" vertex="1">
          <mxGeometry height="50" width="50" x="150" y="530" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=32;" value="🖥️" vertex="1">
          <mxGeometry height="50" width="50" x="700" y="530" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f1f5f9;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="35" width="700" x="100" y="660" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#64748b;" value="💡 一次编写,到处运行 · Write Once, Run Anywhere" vertex="1">
          <mxGeometry height="25" width="400" x="250" y="665" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
JVM 的多种实现
JVM 实现 开发商 特点
HotSpot Oracle/OpenJDK 最主流,默认 JVM
OpenJ9 IBM/Eclipse 低内存占用,快速启动
GraalVM Oracle 支持多语言,AOT 编译
Azul Zing Azul 超低延迟 GC
Dragonwell Alibaba 针对电商场景优化

JRE(Java Runtime Environment)

// JRE 核心类库示例

// java.lang - 自动导入,无需 import
String str = "Hello";          // java.lang.String
Integer num = 100;             // java.lang.Integer
Thread thread = new Thread();  // java.lang.Thread

// java.util - 集合框架
import java.util.ArrayList;
import java.util.HashMap;
List<String> list = new ArrayList<>();
Map<String, Integer> map = new HashMap<>();

// java.io - 输入输出
import java.io.File;
import java.io.FileInputStream;
File file = new File("test.txt");

// java.net - 网络编程
import java.net.URL;
import java.net.HttpURLConnection;
URL url = new URL("https://example.com");

JDK(Java Development Kit)

# JDK 目录结构 (JDK 11+)
jdk-17/
├── bin/                    # 开发工具
│   ├── java                # 运行 Java 程序
│   ├── javac               # 编译器
│   ├── javadoc             # 文档生成
│   ├── jdb                 # 调试器
│   ├── jar                 # 打包工具
│   ├── jlink               # 自定义运行时镜像
│   ├── jshell              # 交互式 REPL (JDK 9+)
│   ├── jconsole            # 监控工具
│   ├── jvisualvm           # 可视化监控 (需单独下载)
│   └── ...
├── conf/                   # 配置文件
├── include/                # C/C++ 头文件 (JNI)
├── jmods/                  # 模块文件 (JDK 9+)
├── lib/                    # 核心类库
│   ├── modules             # 模块化类库
│   └── src.zip             # 源码
└── legal/                  # 许可证文件
# 常用 JDK 工具命令

# 编译 Java 文件
javac HelloWorld.java

# 运行 Java 程序
java HelloWorld

# 查看字节码
javap -c HelloWorld.class

# 生成文档
javadoc -d docs *.java

# 打包 JAR
jar cvf app.jar *.class

# 交互式 Shell (JDK 9+)
jshell

# 创建自定义运行时 (JDK 9+)
jlink --module-path $JAVA_HOME/jmods \
      --add-modules java.base \
      --output custom-runtime

1.3 重要变化

<mxfile>
  <diagram id="jdk-version-evolution" name="JDK 版本演进重要变化">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="850" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="800" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#1e40af;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 版本演进重要变化" vertex="1">
          <mxGeometry height="55" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="760" x="70" y="105" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 8 及之前" vertex="1">
          <mxGeometry height="35" width="150" x="90" y="120" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="📦" vertex="1">
          <mxGeometry height="40" width="40" x="250" y="118" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d97706;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="150" width="280" x="100" y="170" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 目录" vertex="1">
          <mxGeometry height="28" width="90" x="110" y="180" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;fontFamily=Courier New;" value="├── bin/" vertex="1">
          <mxGeometry height="22" width="120" x="120" y="215" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef3c7;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;fontFamily=Courier New;fontStyle=1;rounded=1;" value="├── jre/" vertex="1">
          <mxGeometry height="22" width="120" x="120" y="240" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;fontFamily=Courier New;" value="├── lib/" vertex="1">
          <mxGeometry height="22" width="120" x="120" y="265" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;fontFamily=Courier New;" value="└── ..." vertex="1">
          <mxGeometry height="22" width="120" x="120" y="290" as="geometry" />
        </mxCell>
        <mxCell id="13" edge="1" parent="1" source="10" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#f59e0b;strokeWidth=3;endArrow=blockThin;endFill=1;endSize=8;dashed=1;" target="15">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#d97706;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="150" width="280" x="440" y="170" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JRE 目录(可独立安装)" vertex="1">
          <mxGeometry height="28" width="180" x="450" y="180" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;fontFamily=Courier New;" value="├── bin/" vertex="1">
          <mxGeometry height="22" width="120" x="460" y="215" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;fontFamily=Courier New;" value="├── lib/" vertex="1">
          <mxGeometry height="22" width="120" x="460" y="240" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;fontFamily=Courier New;" value="└── ..." vertex="1">
          <mxGeometry height="22" width="120" x="460" y="265" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#dcfce7;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;" value="✓ 独立分发" vertex="1">
          <mxGeometry height="25" width="100" x="600" y="250" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="180" width="760" x="70" y="355" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 9+" vertex="1">
          <mxGeometry height="35" width="100" x="90" y="370" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="🔧" vertex="1">
          <mxGeometry height="40" width="40" x="200" y="368" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#2563eb;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="340" x="100" y="420" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="⚡ 引入模块化系统 (JPMS)" vertex="1">
          <mxGeometry height="25" width="300" x="115" y="430" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#dbeafe;align=left;verticalAlign=middle;fontSize=11;fontColor=#3b82f6;fontStyle=2;rounded=1;" value="Java Platform Module System" vertex="1">
          <mxGeometry height="20" width="200" x="130" y="455" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=0;fontColor=#dc2626;" value="✗ JDK 目录不再包含独立 jre/" vertex="1">
          <mxGeometry height="25" width="250" x="115" y="480" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#2563eb;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="340" x="470" y="420" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🔗 jlink 定制化运行时" vertex="1">
          <mxGeometry height="30" width="180" x="490" y="435" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="按需打包所需模块" vertex="1">
          <mxGeometry height="20" width="150" x="490" y="470" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="更小的运行时体积" vertex="1">
          <mxGeometry height="20" width="150" x="490" y="490" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="📦" vertex="1">
          <mxGeometry height="50" width="50" x="700" y="445" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="235" width="760" x="70" y="555" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 11+" vertex="1">
          <mxGeometry height="35" width="100" x="90" y="570" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="⚠️" vertex="1">
          <mxGeometry height="40" width="40" x="200" y="568" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#db2777;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="155" width="340" x="100" y="625" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="重要变更" vertex="1">
          <mxGeometry height="25" width="80" x="115" y="630" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="✗ Oracle 不再提供独立 JRE 下载" vertex="1">
          <mxGeometry height="22" width="280" x="115" y="665" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 推荐使用 jlink 按需定制运行时" vertex="1">
          <mxGeometry height="22" width="280" x="115" y="695" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b45309;" value="💰 Oracle JDK 商业使用需付费" vertex="1">
          <mxGeometry height="22" width="280" x="115" y="725" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=#dcfce7;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;" value="✓ OpenJDK 仍然免费" vertex="1">
          <mxGeometry height="20" width="150" x="130" y="750" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#db2777;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="155" width="340" x="470" y="626" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="推荐方案" vertex="1">
          <mxGeometry height="25" width="80" x="485" y="630" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#dbeafe;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#1e40af;rounded=1;" value="OpenJDK" vertex="1">
          <mxGeometry height="35" width="120" x="500" y="670" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" value="免费开源" vertex="1">
          <mxGeometry height="18" width="100" x="510" y="705" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef3c7;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#b45309;rounded=1;" value="Amazon Corretto" vertex="1">
          <mxGeometry height="35" width="140" x="640" y="670" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" value="免费 + 长期支持" vertex="1">
          <mxGeometry height="18" width="120" x="650" y="705" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#4f46e5;rounded=1;" value="Adoptium (Eclipse)" vertex="1">
          <mxGeometry height="35" width="150" x="500" y="730" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" value="社区维护" vertex="1">
          <mxGeometry height="18" width="100" x="520" y="765" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#dcfce7;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;rounded=1;" value="Azul Zulu" vertex="1">
          <mxGeometry height="35" width="110" x="670" y="730" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#64748b;" value="企业级支持" vertex="1">
          <mxGeometry height="18" width="100" x="675" y="765" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
// JDK 9+ 模块化示例
// module-info.java
module com.myapp {
    requires java.base;        // 基础模块(默认)
    requires java.sql;         // 数据库模块
    requires java.logging;     // 日志模块

    exports com.myapp.api;     // 导出包供其他模块使用
}

二、字节码详解

2.1 什么是字节码

<mxfile>
  <diagram id="bytecode-essence" name="字节码的本质">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="640" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=26;fontStyle=1;fontColor=#ffffff;rounded=1;" value="字节码的本质" vertex="1">
          <mxGeometry height="60" width="820" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="140" width="760" x="70" y="110" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#4338ca;" value="📋 字节码 (Bytecode) 是一种中间代码格式" vertex="1">
          <mxGeometry height="35" width="450" x="100" y="125" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#a5b4fc;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="100" y="165" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#4338ca;" value="🖥️ 不针对特定 CPU 架构" vertex="1">
          <mxGeometry height="30" width="160" x="105" y="185" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#a5b4fc;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="140" x="290" y="165" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#4338ca;" value="☕ 只面向 JVM" vertex="1">
          <mxGeometry height="30" width="130" x="295" y="185" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#a5b4fc;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="450" y="165" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#4338ca;" value="📄 存储在 .class 文件中" vertex="1">
          <mxGeometry height="30" width="160" x="455" y="185" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#a5b4fc;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="640" y="165" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#4338ca;" value="🔢 单字节操作码 (opcode)" vertex="1">
          <mxGeometry height="25" width="160" x="645" y="180" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#c7d2fe;align=center;verticalAlign=middle;fontSize=11;fontColor=#6366f1;rounded=1;" value="故称&quot;字节码&quot;" vertex="1">
          <mxGeometry height="20" width="100" x="675" y="205" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0fdf4;strokeColor=#22c55e;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="380" width="760" x="70" y="270" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="编译与执行流程" vertex="1">
          <mxGeometry height="30" width="140" x="90" y="285" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="140" width="180" x="110" y="340" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="源代码" vertex="1">
          <mxGeometry height="40" width="120" x="140" y="355" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#b45309;rounded=1;" value=".java" vertex="1">
          <mxGeometry height="30" width="90" x="155" y="405" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="📝" vertex="1">
          <mxGeometry height="40" width="60" x="170" y="435" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="140" width="180" x="360" y="340" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="字节码" vertex="1">
          <mxGeometry height="40" width="120" x="390" y="355" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#1d4ed8;rounded=1;" value=".class" vertex="1">
          <mxGeometry height="30" width="90" x="405" y="405" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="📦" vertex="1">
          <mxGeometry height="40" width="60" x="420" y="435" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="140" width="180" x="610" y="340" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="机器码" vertex="1">
          <mxGeometry height="40" width="120" x="640" y="355" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#be185d;rounded=1;" value="二进制" vertex="1">
          <mxGeometry height="30" width="90" x="655" y="405" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="⚡" vertex="1">
          <mxGeometry height="40" width="60" x="670" y="435" as="geometry" />
        </mxCell>
        <mxCell id="29" edge="1" parent="1" source="17" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#f59e0b;strokeWidth=4;endArrow=blockThin;endFill=1;endSize=10;" target="21">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef3c7;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#b45309;rounded=1;" value="javac 编译" vertex="1">
          <mxGeometry height="25" width="80" x="285" y="376" as="geometry" />
        </mxCell>
        <mxCell id="31" edge="1" parent="1" source="21" style="edgeStyle=orthogonalEdgeStyle;strokeColor=#3b82f6;strokeWidth=4;endArrow=blockThin;endFill=1;endSize=10;" target="25">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#dbeafe;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#1d4ed8;rounded=1;" value="JVM 执行" vertex="1">
          <mxGeometry height="25" width="75" x="537" y="375" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="130" width="180" x="110" y="500" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#b45309;" value="高级语言" vertex="1">
          <mxGeometry height="25" width="120" x="140" y="515" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontColor=#92400e;rounded=1;" value="👤 人类可读" vertex="1">
          <mxGeometry height="28" width="130" x="135" y="550" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontColor=#92400e;rounded=1;" value="🌍 平台无关" vertex="1">
          <mxGeometry height="28" width="130" x="135" y="588" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="130" width="180" x="360" y="500" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1d4ed8;" value="中间代码" vertex="1">
          <mxGeometry height="25" width="120" x="390" y="515" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;rounded=1;" value="☕ JVM 可读" vertex="1">
          <mxGeometry height="28" width="130" x="385" y="550" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;rounded=1;" value="🌍 平台无关" vertex="1">
          <mxGeometry height="28" width="130" x="385" y="588" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="130" width="180" x="610" y="500" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#be185d;" value="CPU 指令" vertex="1">
          <mxGeometry height="25" width="120" x="640" y="515" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontColor=#9d174d;rounded=1;" value="🖥️ 机器可执行" vertex="1">
          <mxGeometry height="28" width="130" x="635" y="550" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontColor=#9d174d;rounded=1;" value="⚠️ 平台相关" vertex="1">
          <mxGeometry height="28" width="130" x="635" y="588" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

2.2 字节码文件结构

<mxfile>
  <diagram id="class-file-structure" name=".class 文件结构">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="750" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="730" width="820" x="40" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=26;fontStyle=1;fontColor=#ffffff;rounded=1;" value=".class 文件结构" vertex="1">
          <mxGeometry height="55" width="820" x="40" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=24;" value="📄" vertex="1">
          <mxGeometry height="45" width="50" x="780" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="740" x="80" y="95" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="魔数 (Magic Number)" vertex="1">
          <mxGeometry height="30" width="180" x="100" y="105" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#b45309;rounded=1;" value="4 字节" vertex="1">
          <mxGeometry height="28" width="70" x="300" y="105" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;fontFamily=Courier New;" value="0xCAFEBABE" vertex="1">
          <mxGeometry height="32" width="150" x="390" y="103" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="← 标识这是一个 Java class 文件" vertex="1">
          <mxGeometry height="28" width="250" x="555" y="105" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="☕" vertex="1">
          <mxGeometry height="30" width="40" x="100" y="130" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="80" width="740" x="80" y="175" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="版本号 (Version)" vertex="1">
          <mxGeometry height="30" width="150" x="100" y="185" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#1d4ed8;rounded=1;" value="2+2 字节" vertex="1">
          <mxGeometry height="28" width="80" x="270" y="185" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="次版本号 + 主版本号" vertex="1">
          <mxGeometry height="28" width="160" x="365" y="185" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#bfdbfe;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;rounded=1;" value="52 = JDK 8" vertex="1">
          <mxGeometry height="25" width="90" x="100" y="222" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#bfdbfe;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;rounded=1;" value="55 = JDK 11" vertex="1">
          <mxGeometry height="25" width="95" x="205" y="222" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#bfdbfe;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;rounded=1;" value="61 = JDK 17" vertex="1">
          <mxGeometry height="25" width="95" x="315" y="222" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="🔢" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="195" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="740" x="80" y="265" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="常量池 (Constant Pool)" vertex="1">
          <mxGeometry height="30" width="190" x="100" y="275" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#166534;" value="存储字面量、符号引用(类名、方法名、字段名等)" vertex="1">
          <mxGeometry height="25" width="400" x="100" y="305" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📚" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="280" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="740" x="80" y="345" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="访问标志 (Access Flags)" vertex="1">
          <mxGeometry height="30" width="195" x="100" y="355" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#be185d;" value="表示类/接口的访问权限和属性" vertex="1">
          <mxGeometry height="25" width="250" x="100" y="385" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=11;fontColor=#be185d;rounded=1;fontFamily=Courier New;" value="public" vertex="1">
          <mxGeometry height="22" width="60" x="360" y="385" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=11;fontColor=#be185d;rounded=1;fontFamily=Courier New;" value="final" vertex="1">
          <mxGeometry height="22" width="50" x="430" y="385" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=11;fontColor=#be185d;rounded=1;fontFamily=Courier New;" value="abstract" vertex="1">
          <mxGeometry height="22" width="70" x="490" y="385" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="🔐" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="360" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="740" x="80" y="425" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="类索引、父类索引、接口索引" vertex="1">
          <mxGeometry height="30" width="250" x="100" y="435" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#4338ca;" value="确定类的继承关系" vertex="1">
          <mxGeometry height="25" width="200" x="100" y="465" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="🔗" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="440" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef9c3;strokeColor=#eab308;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="740" x="80" y="505" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#eab308;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="字段表 (Fields)" vertex="1">
          <mxGeometry height="30" width="140" x="100" y="515" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#a16207;" value="类中定义的成员变量" vertex="1">
          <mxGeometry height="25" width="200" x="260" y="520" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📋" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="515" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d1fae5;strokeColor=#10b981;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="740" x="80" y="575" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#10b981;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="方法表 (Methods)" vertex="1">
          <mxGeometry height="30" width="155" x="100" y="585" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#059669;" value="类中定义的方法,包含字节码指令" vertex="1">
          <mxGeometry height="25" width="280" x="100" y="615" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="⚙️" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="590" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f3e8ff;strokeColor=#a855f7;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="740" x="80" y="655" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#a855f7;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="属性表 (Attributes)" vertex="1">
          <mxGeometry height="30" width="170" x="100" y="665" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#7e22ce;" value="附加信息:源文件名、行号表、注解等" vertex="1">
          <mxGeometry height="25" width="300" x="290" y="670" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📎" vertex="1">
          <mxGeometry height="40" width="40" x="760" y="660" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

2.3 字节码实战分析

// 源代码: HelloWorld.java
public class HelloWorld {
    private int count = 0;

    public int add(int a, int b) {
        return a + b;
    }

    public static void main(String[] args) {
        HelloWorld hw = new HelloWorld();
        int result = hw.add(1, 2);
        System.out.println(result);
    }
}

javap反编译:

# 编译
javac HelloWorld.java

# 反编译查看字节码
javap -v -p HelloWorld.class

字节码输出分析

Classfile /path/to/HelloWorld.class
  Last modified 2024-1-1; size 537 bytes
  SHA-256 checksum abc123...
  Compiled from "HelloWorld.java"

// ==================== 类信息 ====================
public class HelloWorld
  minor version: 0
  major version: 61                    // JDK 17
  flags: (0x0021) ACC_PUBLIC, ACC_SUPER
  this_class: #8                       // HelloWorld
  super_class: #2                      // java/lang/Object
  interfaces: 0, fields: 1, methods: 3, attributes: 1

// ==================== 常量池 ====================
Constant pool:
   #1 = Methodref    #2.#3      // java/lang/Object."<init>":()V
   #2 = Class        #4         // java/lang/Object
   #3 = NameAndType  #5:#6      // "<init>":()V
   #4 = Utf8         java/lang/Object
   #5 = Utf8         <init>
   #6 = Utf8         ()V
   #7 = Fieldref     #8.#9      // HelloWorld.count:I
   #8 = Class        #10        // HelloWorld
   ...

// ==================== 字段定义 ====================
  private int count;
    descriptor: I                       // I 表示 int 类型
    flags: (0x0002) ACC_PRIVATE

// ==================== 方法: add ====================
  public int add(int, int);
    descriptor: (II)I                   // 参数: 2个int, 返回: int
    flags: (0x0001) ACC_PUBLIC
    Code:
      stack=2, locals=3, args_size=3    // 操作数栈深度=2, 局部变量=3
         0: iload_1       // 将第1个int参数压入操作数栈
         1: iload_2       // 将第2个int参数压入操作数栈
         2: iadd          // 弹出两个int相加,结果压栈
         3: ireturn       // 返回栈顶int值
      LineNumberTable:
        line 5: 0         // 源代码第5行对应字节码偏移0

// ==================== 方法: main ====================
  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: (0x0009) ACC_PUBLIC, ACC_STATIC
    Code:
      stack=3, locals=3, args_size=1
         0: new           #8    // 创建 HelloWorld 对象
         3: dup                 // 复制栈顶引用
         4: invokespecial #1    // 调用构造方法 <init>
         7: astore_1            // 存储到局部变量1
         8: aload_1             // 加载局部变量1
         9: iconst_1            // 常量1压栈
        10: iconst_2            // 常量2压栈
        11: invokevirtual #11   // 调用 add 方法
        14: istore_2            // 存储结果到局部变量2
        15: getstatic     #12   // 获取 System.out
        18: iload_2             // 加载结果
        19: invokevirtual #18   // 调用 println
        22: return              // 返回

2.4 常见字节码指令

<mxfile>
  <diagram id="bytecode-instructions" name="常见字节码指令分类">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="900" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="880" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=26;fontStyle=1;fontColor=#ffffff;rounded=1;" value="常见字节码指令分类" vertex="1">
          <mxGeometry height="55" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=24;" value="⚙️" vertex="1">
          <mxGeometry height="45" width="50" x="990" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="490" x="60" y="95" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📥 加载/存储指令" vertex="1">
          <mxGeometry height="35" width="180" x="80" y="110" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;rounded=1;fontFamily=Courier New;fontStyle=1;" value="iload, iload_&lt;n&gt;" vertex="1">
          <mxGeometry height="26" width="130" x="80" y="155" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="加载 int 到操作数栈" vertex="1">
          <mxGeometry height="26" width="150" x="220" y="155" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;rounded=1;fontFamily=Courier New;fontStyle=1;" value="istore, istore_&lt;n&gt;" vertex="1">
          <mxGeometry height="26" width="130" x="80" y="186" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="将 int 存入局部变量表" vertex="1">
          <mxGeometry height="26" width="160" x="220" y="186" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;rounded=1;fontFamily=Courier New;fontStyle=1;" value="aload, aload_&lt;n&gt;" vertex="1">
          <mxGeometry height="26" width="130" x="80" y="217" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="加载引用类型" vertex="1">
          <mxGeometry height="26" width="120" x="220" y="217" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;rounded=1;fontFamily=Courier New;fontStyle=1;" value="ldc" vertex="1">
          <mxGeometry height="26" width="130" x="80" y="248" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="加载常量池中的常量" vertex="1">
          <mxGeometry height="26" width="150" x="220" y="248" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;rounded=1;fontFamily=Courier New;fontStyle=1;" value="iconst_&lt;n&gt;" vertex="1">
          <mxGeometry height="26" width="130" x="80" y="279" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="加载 int 常量 (-1~5)" vertex="1">
          <mxGeometry height="26" width="150" x="220" y="279" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;rounded=1;fontFamily=Courier New;fontStyle=1;" value="bipush, sipush" vertex="1">
          <mxGeometry height="26" width="130" x="380" y="155" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="加载 byte/short 常量" vertex="1">
          <mxGeometry height="26" width="150" x="380" y="186" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="480" x="570" y="95" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🔢 算术指令" vertex="1">
          <mxGeometry height="35" width="140" x="590" y="110" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#1d4ed8;rounded=1;fontFamily=Courier New;fontStyle=1;" value="iadd, isub, imul, idiv" vertex="1">
          <mxGeometry height="26" width="180" x="590" y="160" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="int 加减乘除" vertex="1">
          <mxGeometry height="26" width="100" x="785" y="160" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#1d4ed8;rounded=1;fontFamily=Courier New;fontStyle=1;" value="ladd, lsub, lmul, ldiv" vertex="1">
          <mxGeometry height="26" width="180" x="590" y="196" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="long 加减乘除" vertex="1">
          <mxGeometry height="26" width="110" x="785" y="196" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#1d4ed8;rounded=1;fontFamily=Courier New;fontStyle=1;" value="fadd, fsub, fmul, fdiv" vertex="1">
          <mxGeometry height="26" width="180" x="590" y="232" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="float 加减乘除" vertex="1">
          <mxGeometry height="26" width="110" x="785" y="232" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#1d4ed8;rounded=1;fontFamily=Courier New;fontStyle=1;" value="dadd, dsub, dmul, ddiv" vertex="1">
          <mxGeometry height="26" width="180" x="590" y="268" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="double 加减乘除" vertex="1">
          <mxGeometry height="26" width="120" x="785" y="268" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#1d4ed8;rounded=1;fontFamily=Courier New;fontStyle=1;" value="iinc" vertex="1">
          <mxGeometry height="26" width="100" x="920" y="160" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="局部变量自增" vertex="1">
          <mxGeometry height="26" width="100" x="920" y="196" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="490" x="60" y="345" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📦 对象/数组指令" vertex="1">
          <mxGeometry height="35" width="175" x="80" y="360" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="new" vertex="1">
          <mxGeometry height="26" width="100" x="80" y="405" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="创建对象" vertex="1">
          <mxGeometry height="26" width="100" x="195" y="405" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="newarray" vertex="1">
          <mxGeometry height="26" width="100" x="80" y="441" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="创建基本类型数组" vertex="1">
          <mxGeometry height="26" width="140" x="195" y="441" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="anewarray" vertex="1">
          <mxGeometry height="26" width="100" x="80" y="477" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="创建引用类型数组" vertex="1">
          <mxGeometry height="26" width="140" x="195" y="477" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="getfield" vertex="1">
          <mxGeometry height="26" width="90" x="340" y="405" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="获取实例字段" vertex="1">
          <mxGeometry height="26" width="100" x="440" y="405" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="putfield" vertex="1">
          <mxGeometry height="26" width="90" x="340" y="441" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="设置实例字段" vertex="1">
          <mxGeometry height="26" width="100" x="440" y="441" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="getstatic" vertex="1">
          <mxGeometry height="26" width="90" x="340" y="477" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="获取静态字段" vertex="1">
          <mxGeometry height="26" width="100" x="440" y="477" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;fontFamily=Courier New;fontStyle=1;" value="putstatic" vertex="1">
          <mxGeometry height="26" width="90" x="340" y="513" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="设置静态字段" vertex="1">
          <mxGeometry height="26" width="100" x="440" y="513" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="480" x="570" y="345" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📞 方法调用指令" vertex="1">
          <mxGeometry height="35" width="170" x="590" y="360" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;fontFamily=Courier New;fontStyle=1;" value="invokevirtual" vertex="1">
          <mxGeometry height="26" width="130" x="590" y="410" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#9d174d;" value="调用实例方法(多态分派)" vertex="1">
          <mxGeometry height="26" width="200" x="735" y="410" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;fontFamily=Courier New;fontStyle=1;" value="invokespecial" vertex="1">
          <mxGeometry height="26" width="130" x="590" y="446" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#9d174d;" value="调用构造方法、私有方法、父类方法" vertex="1">
          <mxGeometry height="26" width="260" x="735" y="446" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;fontFamily=Courier New;fontStyle=1;" value="invokestatic" vertex="1">
          <mxGeometry height="26" width="130" x="590" y="482" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#9d174d;" value="调用静态方法" vertex="1">
          <mxGeometry height="26" width="120" x="735" y="482" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#ffffff;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;fontFamily=Courier New;fontStyle=1;" value="invokeinterface" vertex="1">
          <mxGeometry height="26" width="130" x="590" y="518" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#9d174d;" value="调用接口方法" vertex="1">
          <mxGeometry height="26" width="120" x="735" y="518" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="text;html=1;strokeColor=none;fillColor=#fdf2f8;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;fontFamily=Courier New;fontStyle=1;strokeColor=#ec4899;" value="invokedynamic" vertex="1">
          <mxGeometry height="26" width="130" x="889" y="410" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#9d174d;" value="动态调用" vertex="1">
          <mxGeometry height="26" width="130" x="894" y="446" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=11;fontColor=#be185d;rounded=1;" value="Lambda、方法引用" vertex="1">
          <mxGeometry height="22" width="130" x="889" y="477" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="260" width="990" x="60" y="595" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🔀 控制转移指令" vertex="1">
          <mxGeometry height="35" width="175" x="80" y="610" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#a5b4fc;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="170" width="290" x="80" y="660" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="text;html=1;strokeColor=none;fillColor=#c7d2fe;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#4338ca;rounded=1;" value="条件跳转" vertex="1">
          <mxGeometry height="28" width="90" x="100" y="675" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="ifeq" vertex="1">
          <mxGeometry height="24" width="50" x="100" y="715" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="ifne" vertex="1">
          <mxGeometry height="24" width="50" x="160" y="715" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="iflt" vertex="1">
          <mxGeometry height="24" width="50" x="220" y="715" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="ifge" vertex="1">
          <mxGeometry height="24" width="50" x="280" y="715" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="ifgt" vertex="1">
          <mxGeometry height="24" width="50" x="100" y="749" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="ifle" vertex="1">
          <mxGeometry height="24" width="50" x="160" y="749" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=11;fontColor=#4338ca;rounded=1;fontFamily=Courier New;" value="if_icmpeq" vertex="1">
          <mxGeometry height="24" width="80" x="220" y="749" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#4338ca;" value="..." vertex="1">
          <mxGeometry height="24" width="50" x="100" y="783" as="geometry" />
        </mxCell>
        <mxCell id="72" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#a5b4fc;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="170" width="200" x="390" y="660" as="geometry" />
        </mxCell>
        <mxCell id="73" parent="1" style="text;html=1;strokeColor=none;fillColor=#c7d2fe;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#4338ca;rounded=1;" value="无条件跳转" vertex="1">
          <mxGeometry height="28" width="100" x="410" y="675" as="geometry" />
        </mxCell>
        <mxCell id="74" parent="1" style="text;html=1;strokeColor=none;fillColor=#e0e7ff;align=center;verticalAlign=middle;fontSize=13;fontColor=#4338ca;rounded=1;fontFamily=Courier New;fontStyle=1;" value="goto" vertex="1">
          <mxGeometry height="28" width="80" x="410" y="720" as="geometry" />
        </mxCell>
        <mxCell id="75" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#4338ca;" value="无条件跳转到指定位置" vertex="1">
          <mxGeometry height="24" width="160" x="410" y="758" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

2.5 字节码执行过程图解

<mxfile>
  <diagram id="add-method-execution" name="add 方法执行过程">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="1050" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="1010" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="add(1, 2) 方法执行过程" vertex="1">
          <mxGeometry height="50" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="⚙️" vertex="1">
          <mxGeometry height="40" width="40" x="1000" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="160" width="980" x="60" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="初始状态" vertex="1">
          <mxGeometry height="35" width="120" x="80" y="105" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#fde68a;align=center;verticalAlign=middle;fontSize=14;fontColor=#92400e;rounded=1;" value="a=1, b=2" vertex="1">
          <mxGeometry height="28" width="90" x="220" y="110" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" value="局部变量表 (locals=3)" vertex="1">
          <mxGeometry height="25" width="170" x="80" y="150" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="80" y="180" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;fontStyle=1;" value="0" vertex="1">
          <mxGeometry height="40" width="25" x="80" y="180" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#b45309;fontFamily=Courier New;" value="this" vertex="1">
          <mxGeometry height="40" width="30" x="98" y="180" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="140" y="180" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="25" x="140" y="180" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#b45309;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="30" x="160" y="180" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="200" y="180" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="25" x="200" y="180" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#b45309;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="30" x="220" y="180" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" value="操作数栈 (stack=2)" vertex="1">
          <mxGeometry height="25" width="150" x="550" y="150" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fefce8;strokeColor=#f59e0b;strokeWidth=2;strokeDasharray=3 3;" value="" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="180" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#ca8a04;fontStyle=2;" value="(空)" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="180" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="160" width="980" x="60" y="270" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;fontFamily=Courier New;" value="iload_1" vertex="1">
          <mxGeometry height="35" width="100" x="80" y="285" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#bfdbfe;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;rounded=1;" value="加载局部变量1" vertex="1">
          <mxGeometry height="26" width="110" x="195" y="290" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="局部变量表" vertex="1">
          <mxGeometry height="25" width="100" x="80" y="330" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="80" y="360" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;fontStyle=1;" value="0" vertex="1">
          <mxGeometry height="40" width="25" x="80" y="360" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#1d4ed8;fontFamily=Courier New;" value="this" vertex="1">
          <mxGeometry height="40" width="30" x="100" y="360" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fef08a;strokeColor=#eab308;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="140" y="360" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="25" x="140" y="360" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#1d4ed8;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="30" x="160" y="360" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="200" y="360" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="25" x="200" y="360" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#1d4ed8;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="30" x="220" y="360" as="geometry" />
        </mxCell>
        <mxCell id="34" edge="1" parent="1" source="30" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#3b82f6;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=0.25;exitY=1;exitDx=0;exitDy=0;" target="36" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points">
              <mxPoint x="168" y="420" />
              <mxPoint x="370" y="420" />
              <mxPoint x="370" y="380" />
            </Array>
            <mxPoint x="280" y="380" as="sourcePoint" />
            <mxPoint x="550" y="380" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="操作数栈" vertex="1">
          <mxGeometry height="25" width="100" x="550" y="330" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fef08a;strokeColor=#eab308;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="360" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;fontColor=#1d4ed8;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="360" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1e40af;fontStyle=1;" value="← 栈顶" vertex="1">
          <mxGeometry height="40" width="60" x="660" y="360" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="160" width="980" x="60" y="450" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;fontFamily=Courier New;" value="iload_2" vertex="1">
          <mxGeometry height="35" width="100" x="80" y="465" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=#bbf7d0;align=center;verticalAlign=middle;fontSize=13;fontColor=#166534;rounded=1;" value="加载局部变量2" vertex="1">
          <mxGeometry height="26" width="110" x="195" y="470" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" value="局部变量表" vertex="1">
          <mxGeometry height="25" width="100" x="80" y="510" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="80" y="540" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontStyle=1;" value="0" vertex="1">
          <mxGeometry height="40" width="25" x="80" y="540" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#15803d;fontFamily=Courier New;" value="this" vertex="1">
          <mxGeometry height="40" width="30" x="100" y="540" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="140" y="540" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="25" x="140" y="540" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#15803d;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="30" x="160" y="540" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fef08a;strokeColor=#eab308;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="200" y="540" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="25" x="200" y="540" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#15803d;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="30" x="220" y="540" as="geometry" />
        </mxCell>
        <mxCell id="52" edge="1" parent="1" source="49" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="54" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points">
              <mxPoint x="400" y="560" />
              <mxPoint x="400" y="533" />
            </Array>
            <mxPoint x="280" y="560" as="sourcePoint" />
            <mxPoint x="550" y="520" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" value="操作数栈" vertex="1">
          <mxGeometry height="25" width="100" x="550" y="483" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fef08a;strokeColor=#eab308;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="513" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;fontColor=#15803d;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="513" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;fontStyle=1;" value="← 栈顶" vertex="1">
          <mxGeometry height="40" width="60" x="660" y="513" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="558" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;fontColor=#15803d;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="558" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="160" width="980" x="60" y="630" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;fontFamily=Courier New;" value="iadd" vertex="1">
          <mxGeometry height="35" width="80" x="80" y="645" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=13;fontColor=#be185d;rounded=1;" value="弹出两个数相加,结果压栈" vertex="1">
          <mxGeometry height="26" width="190" x="175" y="650" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#be185d;" value="局部变量表" vertex="1">
          <mxGeometry height="25" width="100" x="80" y="690" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="80" y="720" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;fontStyle=1;" value="0" vertex="1">
          <mxGeometry height="40" width="25" x="80" y="720" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#db2777;fontFamily=Courier New;" value="this" vertex="1">
          <mxGeometry height="40" width="30" x="98" y="720" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="140" y="720" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="25" x="140" y="720" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#db2777;fontStyle=1;" value="1" vertex="1">
          <mxGeometry height="40" width="30" x="160" y="720" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="40" width="50" x="200" y="720" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="25" x="200" y="720" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#db2777;fontStyle=1;" value="2" vertex="1">
          <mxGeometry height="40" width="30" x="220" y="720" as="geometry" />
        </mxCell>
        <mxCell id="72" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef08a;align=center;verticalAlign=middle;fontSize=18;fontColor=#b45309;fontStyle=1;rounded=1;strokeColor=#eab308;strokeWidth=2;" value="1 + 2 = 3" vertex="1">
          <mxGeometry height="40" width="120" x="380" y="720" as="geometry" />
        </mxCell>
        <mxCell id="73" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#be185d;" value="操作数栈" vertex="1">
          <mxGeometry height="25" width="100" x="550" y="690" as="geometry" />
        </mxCell>
        <mxCell id="74" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fef08a;strokeColor=#eab308;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="720" as="geometry" />
        </mxCell>
        <mxCell id="75" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;fontColor=#db2777;fontStyle=1;" value="3" vertex="1">
          <mxGeometry height="40" width="100" x="550" y="720" as="geometry" />
        </mxCell>
        <mxCell id="76" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;fontStyle=1;" value="← 栈顶" vertex="1">
          <mxGeometry height="40" width="60" x="660" y="720" as="geometry" />
        </mxCell>
        <mxCell id="77" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="150" width="980" x="60" y="810" as="geometry" />
        </mxCell>
        <mxCell id="78" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;fontFamily=Courier New;" value="ireturn" vertex="1">
          <mxGeometry height="35" width="100" x="80" y="825" as="geometry" />
        </mxCell>
        <mxCell id="79" parent="1" style="text;html=1;strokeColor=none;fillColor=#c7d2fe;align=center;verticalAlign=middle;fontSize=13;fontColor=#4338ca;rounded=1;" value="返回栈顶值" vertex="1">
          <mxGeometry height="26" width="100" x="195" y="830" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

三、编译与解释并存

3.1 编程语言执行方式分类

<mxfile>
  <diagram id="programming-language-execution" name="编程语言执行方式对比">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="900" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="880" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="编程语言执行方式对比" vertex="1">
          <mxGeometry height="50" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="⚡" vertex="1">
          <mxGeometry height="40" width="40" x="1000" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="980" x="60" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="编译型语言" vertex="1">
          <mxGeometry height="40" width="150" x="80" y="105" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#bfdbfe;align=center;verticalAlign=middle;fontSize=14;fontColor=#1e40af;rounded=1;" value="代表: C / C++ / Go / Rust" vertex="1">
          <mxGeometry height="28" width="200" x="250" y="112" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="源代码" vertex="1">
          <mxGeometry height="50" width="100" x="100" y="170" as="geometry" />
        </mxCell>
        <mxCell id="9" edge="1" parent="1" source="8" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#3b82f6;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="10" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="210" y="195" as="sourcePoint" />
            <mxPoint x="260" y="195" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#60a5fa;strokeColor=#2563eb;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="编译器" vertex="1">
          <mxGeometry height="50" width="100" x="260" y="170" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="(一次性)" vertex="1">
          <mxGeometry height="20" width="100" x="260" y="220" as="geometry" />
        </mxCell>
        <mxCell id="12" edge="1" parent="1" source="10" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#3b82f6;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="13" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="370" y="195" as="sourcePoint" />
            <mxPoint x="420" y="195" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="机器码" vertex="1">
          <mxGeometry height="50" width="100" x="420" y="170" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;" value="(可执行文件)" vertex="1">
          <mxGeometry height="20" width="100" x="420" y="220" as="geometry" />
        </mxCell>
        <mxCell id="15" edge="1" parent="1" source="13" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#3b82f6;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="16" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="530" y="195" as="sourcePoint" />
            <mxPoint x="580" y="195" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="直接执行" vertex="1">
          <mxGeometry height="50" width="100" x="580" y="170" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#93c5fd;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="80" width="300" x="720" y="155" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#166534;fontStyle=1;" value="✅ 优点: 执行速度快" vertex="1">
          <mxGeometry height="30" width="260" x="740" y="165" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#dc2626;fontStyle=1;" value="❌ 缺点: 开发周期长,不跨平台" vertex="1">
          <mxGeometry height="30" width="260" x="740" y="200" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="980" x="60" y="340" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="解释型语言" vertex="1">
          <mxGeometry height="40" width="150" x="80" y="355" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#fde68a;align=center;verticalAlign=middle;fontSize=14;fontColor=#92400e;rounded=1;" value="代表: Python / JavaScript / Ruby" vertex="1">
          <mxGeometry height="28" width="250" x="250" y="362" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f59e0b;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#92400e;" value="源代码" vertex="1">
          <mxGeometry height="50" width="100" x="100" y="420" as="geometry" />
        </mxCell>
        <mxCell id="24" edge="1" parent="1" source="23" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#f59e0b;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="25" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="210" y="445" as="sourcePoint" />
            <mxPoint x="260" y="445" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fbbf24;strokeColor=#d97706;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="解释器" vertex="1">
          <mxGeometry height="50" width="100" x="260" y="420" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="(边翻译边执行)" vertex="1">
          <mxGeometry height="20" width="120" x="250" y="470" as="geometry" />
        </mxCell>
        <mxCell id="27" edge="1" parent="1" source="25" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#f59e0b;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="28" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="370" y="445" as="sourcePoint" />
            <mxPoint x="420" y="445" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="逐行翻译执行" vertex="1">
          <mxGeometry height="50" width="130" x="420" y="420" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fcd34d;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="80" width="300" x="720" y="405" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#166534;fontStyle=1;" value="✅ 优点: 开发效率高,跨平台" vertex="1">
          <mxGeometry height="30" width="260" x="740" y="415" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#dc2626;fontStyle=1;" value="❌ 缺点: 执行速度较慢" vertex="1">
          <mxGeometry height="30" width="260" x="740" y="450" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="270" width="980" x="60" y="590" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" value="混合型语言 (Java)" vertex="1">
          <mxGeometry height="40" width="200" x="80" y="605" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="⭐" vertex="1">
          <mxGeometry height="35" width="40" x="290" y="610" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#166534;" value="源代码" vertex="1">
          <mxGeometry height="50" width="90" x="100" y="680" as="geometry" />
        </mxCell>
        <mxCell id="36" edge="1" parent="1" source="35" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="37" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="200" y="705" as="sourcePoint" />
            <mxPoint x="250" y="705" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4ade80;strokeColor=#16a34a;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="编译器" vertex="1">
          <mxGeometry height="50" width="90" x="230" y="680" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontFamily=Courier New;" value="(javac)" vertex="1">
          <mxGeometry height="20" width="90" x="230" y="730" as="geometry" />
        </mxCell>
        <mxCell id="39" edge="1" parent="1" source="37" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="40" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="330" y="705" as="sourcePoint" />
            <mxPoint x="380" y="705" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#22c55e;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#166534;" value="字节码" vertex="1">
          <mxGeometry height="50" width="90" x="360" y="680" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontFamily=Courier New;" value="(.class)" vertex="1">
          <mxGeometry height="20" width="90" x="360" y="730" as="geometry" />
        </mxCell>
        <mxCell id="42" edge="1" parent="1" source="40" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="43" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="460" y="705" as="sourcePoint" />
            <mxPoint x="510" y="705" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4ade80;strokeColor=#16a34a;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="解释器/JIT" vertex="1">
          <mxGeometry height="50" width="110" x="490" y="680" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontFamily=Courier New;" value="(JVM)" vertex="1">
          <mxGeometry height="20" width="110" x="490" y="730" as="geometry" />
        </mxCell>
        <mxCell id="45" edge="1" parent="1" source="43" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="46" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="610" y="705" as="sourcePoint" />
            <mxPoint x="660" y="705" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="46" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#16a34a;strokeColor=#15803d;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="执行" vertex="1">
          <mxGeometry height="50" width="80" x="640" y="680" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#86efac;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="80" width="260" x="760" y="665" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=15;fontColor=#166534;fontStyle=1;" value="🎯 兼具两者优点" vertex="1">
          <mxGeometry height="30" width="220" x="780" y="675" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#bbf7d0;align=center;verticalAlign=middle;fontSize=14;fontColor=#166534;fontStyle=1;rounded=1;" value="跨平台 + 较高性能" vertex="1">
          <mxGeometry height="28" width="150" x="780" y="710" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#86efac;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;rounded=1;" value="编译阶段" vertex="1">
          <mxGeometry height="24" width="220" x="230" y="760" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=#fde68a;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;rounded=1;" value="运行阶段" vertex="1">
          <mxGeometry height="24" width="230" x="490" y="760" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#166534;" value="一次编译" vertex="1">
          <mxGeometry height="30" width="240" x="220" y="800" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#92400e;" value="多次运行(Write Once, Run Anywhere)" vertex="1">
          <mxGeometry height="30" width="260" x="480" y="800" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

3.2 Java 程序完整执行流程

<mxfile>
  <diagram id="java-execution-flow" name="Java 程序执行流程">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="1050" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="1010" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Java 程序执行流程" vertex="1">
          <mxGeometry height="50" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="☕" vertex="1">
          <mxGeometry height="40" width="40" x="1000" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;fontSize=16;fontStyle=1;fontColor=#1e40af;" value="Hello.java" vertex="1">
          <mxGeometry height="50" width="180" x="460" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#3b82f6;" value="(源代码)" vertex="1">
          <mxGeometry height="20" width="180" x="460" y="140" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📄" vertex="1">
          <mxGeometry height="40" width="40" x="420" y="95" as="geometry" />
        </mxCell>
        <mxCell id="8" edge="1" parent="1" source="5" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#f59e0b;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="11" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="150" as="sourcePoint" />
            <mxPoint x="550" y="210" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef3c7;align=center;verticalAlign=middle;fontSize=13;fontColor=#92400e;fontStyle=1;rounded=1;" value="javac 编译" vertex="1">
          <mxGeometry height="24" width="90" x="560" y="165" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#b45309;" value="(前端编译)" vertex="1">
          <mxGeometry height="24" width="70" x="650" y="165" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;fontSize=16;fontStyle=1;fontColor=#92400e;" value="Hello.class" vertex="1">
          <mxGeometry height="50" width="180" x="460" y="210" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#f59e0b;" value="(字节码)" vertex="1">
          <mxGeometry height="20" width="180" x="460" y="260" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📦" vertex="1">
          <mxGeometry height="40" width="40" x="420" y="215" as="geometry" />
        </mxCell>
        <mxCell id="14" edge="1" parent="1" source="11" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="16" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="270" as="sourcePoint" />
            <mxPoint x="550" y="330" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#dcfce7;align=center;verticalAlign=middle;fontSize=13;fontColor=#166534;fontStyle=1;rounded=1;" value="java 命令启动 JVM" vertex="1">
          <mxGeometry height="24" width="140" x="560" y="285" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0fdf4;strokeColor=#22c55e;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="620" width="900" x="100" y="330" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JVM (Java Virtual Machine)" vertex="1">
          <mxGeometry height="40" width="900" x="100" y="330" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="🖥️" vertex="1">
          <mxGeometry height="36" width="40" x="950" y="332" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="820" x="140" y="390" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="类加载子系统 (Class Loader Subsystem)" vertex="1">
          <mxGeometry height="30" width="320" x="160" y="405" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="加载" vertex="1">
          <mxGeometry height="30" width="80" x="180" y="450" as="geometry" />
        </mxCell>
        <mxCell id="22" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="270" y="465" as="sourcePoint" />
            <mxPoint x="310" y="465" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="链接" vertex="1">
          <mxGeometry height="30" width="200" x="320" y="450" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#1e40af;" value="(验证/准备/解析)" vertex="1">
          <mxGeometry height="30" width="160" x="340" y="460" as="geometry" />
        </mxCell>
        <mxCell id="25" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="530" y="465" as="sourcePoint" />
            <mxPoint x="570" y="465" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#3b82f6;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#1e40af;" value="初始化" vertex="1">
          <mxGeometry height="30" width="80" x="580" y="450" as="geometry" />
        </mxCell>
        <mxCell id="27" edge="1" parent="1" source="19" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#6366f1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="28" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="500" as="sourcePoint" />
            <mxPoint x="550" y="530" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="300" width="820" x="140" y="510" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="执行引擎 (Execution Engine)" vertex="1">
          <mxGeometry height="30" width="250" x="160" y="525" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="⚙️" vertex="1">
          <mxGeometry height="34" width="30" x="410" y="523" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="120" width="200" x="180" y="575" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="解释器" vertex="1">
          <mxGeometry height="26" width="80" x="200" y="585" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#92400e;" value="(Interpreter)" vertex="1">
          <mxGeometry height="26" width="80" x="280" y="585" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#92400e;fontStyle=1;" value="逐行解释执行" vertex="1">
          <mxGeometry height="25" width="200" x="180" y="620" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="✅ 启动快" vertex="1">
          <mxGeometry height="20" width="100" x="180" y="645" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#dc2626;" value="❌ 执行慢" vertex="1">
          <mxGeometry height="20" width="100" x="280" y="645" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" value="🐢" vertex="1">
          <mxGeometry height="25" width="40" x="250" y="665" as="geometry" />
        </mxCell>
        <mxCell id="38" edge="1" parent="1" source="31" style="endArrow=classic;startArrow=classic;html=1;strokeWidth=3;strokeColor=#8b5cf6;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="40" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="390" y="635" as="sourcePoint" />
            <mxPoint x="440" y="635" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=#ede9fe;align=center;verticalAlign=middle;fontSize=12;fontColor=#7c3aed;fontStyle=1;rounded=1;" value="协同工作" vertex="1">
          <mxGeometry height="22" width="70" x="400" y="610" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="120" width="240" x="490" y="575" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JIT 编译器" vertex="1">
          <mxGeometry height="26" width="100" x="510" y="585" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#be185d;" value="(Just-In-Time)" vertex="1">
          <mxGeometry height="26" width="100" x="610" y="585" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#be185d;fontStyle=1;" value="热点代码编译成机器码" vertex="1">
          <mxGeometry height="25" width="240" x="490" y="620" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#dc2626;" value="❌ 编译慢" vertex="1">
          <mxGeometry height="20" width="120" x="490" y="645" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="✅ 执行快" vertex="1">
          <mxGeometry height="20" width="120" x="610" y="645" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" value="🚀" vertex="1">
          <mxGeometry height="25" width="40" x="590" y="665" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="80" width="170" x="770" y="595" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Code Cache" vertex="1">
          <mxGeometry height="26" width="130" x="790" y="605" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;" value="(机器码缓存)" vertex="1">
          <mxGeometry height="20" width="170" x="770" y="635" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" value="💾" vertex="1">
          <mxGeometry height="25" width="40" x="830" y="650" as="geometry" />
        </mxCell>
        <mxCell id="52" edge="1" parent="1" source="40" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#ec4899;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" target="48" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="740" y="635" as="sourcePoint" />
            <mxPoint x="770" y="635" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="53" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="750" x="180" y="720" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#92400e;fontStyle=1;" value="混合模式执行:解释器快速启动 + JIT 优化热点代码 = 最佳性能" vertex="1">
          <mxGeometry height="40" width="750" x="180" y="735" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="⚡" vertex="1">
          <mxGeometry height="50" width="30" x="890" y="730" as="geometry" />
        </mxCell>
        <mxCell id="56" edge="1" parent="1" source="28" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#64748b;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="57" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="820" as="sourcePoint" />
            <mxPoint x="550" y="860" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="57" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f1f5f9;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="820" x="140" y="830" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=#64748b;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="操作系统 / 硬件" vertex="1">
          <mxGeometry height="30" width="160" x="160" y="845" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontColor=#475569;fontStyle=1;" value="执行机器码 (Native Code)" vertex="1">
          <mxGeometry height="30" width="820" x="140" y="885" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="text;html=1;strokeColor=none;fillColor=#e2e8f0;align=center;verticalAlign=middle;fontSize=14;fontColor=#475569;rounded=1;" value="🖥️ CPU" vertex="1">
          <mxGeometry height="30" width="80" x="760" y="855" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=#e2e8f0;align=center;verticalAlign=middle;fontSize=14;fontColor=#475569;rounded=1;" value="💻 内存" vertex="1">
          <mxGeometry height="30" width="80" x="860" y="855" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

3.3 为什么说 Java 是"编译与解释并存"

// 一段 Java 代码的执行过程

public class Demo {
    public static void main(String[] args) {
        // 循环执行 10000 次
        for (int i = 0; i < 10000; i++) {
            calculate(i);
        }
    }

    public static int calculate(int n) {
        return n * n + n;
    }
}

执行过程

<mxfile>
  <diagram id="hybrid-execution-mode" name="混合执行模式详解">
    <mxGraphModel dx="788" dy="843" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1200" pageHeight="900" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fafafa;strokeColor=#424242;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="850" width="920" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#424242;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#ffffff;" value="混合执行模式详解" vertex="1">
          <mxGeometry height="45" width="920" x="40" y="30" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e3f2fd;strokeColor=#1976d2;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="150" width="880" x="60" y="95" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#1976d2;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#ffffff;spacingLeft=10;" value="阶段1: 编译阶段" vertex="1">
          <mxGeometry height="28" width="140" x="70" y="105" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#bbdefb;strokeColor=#1976d2;fontSize=11;fontColor=#1565c0;" value="编译型特征" vertex="1">
          <mxGeometry height="28" width="80" x="220" y="105" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fff9c4;strokeColor=#f9a825;strokeWidth=2;fontSize=13;fontStyle=1;" value="Demo.java" vertex="1">
          <mxGeometry height="45" width="120" x="100" y="155" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#1976d2;strokeColor=#0d47a1;fontColor=#ffffff;fontSize=12;fontStyle=1;" value="javac" vertex="1">
          <mxGeometry height="45" width="70" x="290" y="155" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#c8e6c9;strokeColor=#43a047;strokeWidth=2;fontSize=13;fontStyle=1;" value="Demo.class" vertex="1">
          <mxGeometry height="45" width="120" x="430" y="155" as="geometry" />
        </mxCell>
        <mxCell id="10" edge="1" parent="1" source="7" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#1976d2;entryX=0;entryY=0.5;exitX=1;exitY=0.5;" target="8" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="11" edge="1" parent="1" source="8" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#1976d2;entryX=0;entryY=0.5;exitX=1;exitY=0.5;" target="9" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#424242;spacingLeft=5;" value="• 词法分析、语法分析、语义分析&#xa;• 生成字节码&#xa;• 这是真正的&quot;编译&quot;" vertex="1">
          <mxGeometry height="60" width="320" x="600" y="145" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fff3e0;strokeColor=#ff9800;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="160" width="880" x="60" y="265" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#ff9800;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#ffffff;spacingLeft=10;" value="阶段2: 程序启动" vertex="1">
          <mxGeometry height="28" width="140" x="70" y="275" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe0b2;strokeColor=#ff9800;fontSize=11;fontColor=#e65100;" value="解释型特征" vertex="1">
          <mxGeometry height="28" width="80" x="220" y="275" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ff9800;strokeColor=#e65100;fontColor=#ffffff;fontSize=13;fontStyle=1;" value="java Demo" vertex="1">
          <mxGeometry height="40" width="110" x="100" y="320" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe0b2;strokeColor=#ff9800;fontSize=11;" value="JVM 启动" vertex="1">
          <mxGeometry height="30" width="90" x="260" y="325" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe0b2;strokeColor=#ff9800;fontSize=11;" value="类加载&#xa;Demo.class" vertex="1">
          <mxGeometry height="44" width="90" x="390" y="318" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe0b2;strokeColor=#ff9800;fontSize=11;" value="解释器&#xa;逐行执行" vertex="1">
          <mxGeometry height="44" width="90" x="520" y="318" as="geometry" />
        </mxCell>
        <mxCell id="20" edge="1" parent="1" source="16" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#ff9800;" target="17" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="21" edge="1" parent="1" source="17" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#ff9800;" target="18" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="22" edge="1" parent="1" source="18" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#ff9800;" target="19" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#424242;spacingLeft=5;" value="• JVM 启动&#xa;• 类加载 Demo.class&#xa;• 解释器逐行执行字节码&#xa;• 立即开始运行,无需等待编译" vertex="1">
          <mxGeometry height="80" width="260" x="660" y="310" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce4ec;strokeColor=#e91e63;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="200" width="880" x="60" y="445" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#e91e63;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#ffffff;spacingLeft=10;" value="阶段3: 热点探测" vertex="1">
          <mxGeometry height="28" width="140" x="70" y="455" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8bbd9;strokeColor=#e91e63;fontSize=11;fontColor=#c2185b;" value="JIT 介入" vertex="1">
          <mxGeometry height="28" width="70" x="220" y="455" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=13;fontStyle=1;fontColor=#424242;" value="calculate() 被调用多次" vertex="1">
          <mxGeometry height="25" width="200" x="80" y="495" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#e91e63;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="100" width="840" x="80" y="525" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontStyle=1;fontColor=#424242;" value="方法调用计数器: calculate() 调用次数" vertex="1">
          <mxGeometry height="22" width="280" x="95" y="530" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#bdbdbd;" value="" vertex="1">
          <mxGeometry height="25" width="760" x="120" y="560" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#ffe0b2;strokeColor=none;fontSize=11;fontStyle=1;fontColor=#e65100;" value="解释执行" vertex="1">
          <mxGeometry height="25" width="456" x="120" y="560" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#c8e6c9;strokeColor=none;fontSize=11;fontStyle=1;fontColor=#2e7d32;" value="JIT 编译" vertex="1">
          <mxGeometry height="25" width="304" x="576" y="560" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fontColor=#757575;" value="0次" vertex="1">
          <mxGeometry height="18" width="40" x="100" y="588" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fontColor=#757575;" value="10000次" vertex="1">
          <mxGeometry height="18" width="50" x="840" y="588" as="geometry" />
        </mxCell>
        <mxCell id="35" edge="1" parent="1" style="endArrow=none;html=1;strokeWidth=2;strokeColor=#e91e63;dashed=1;" value="">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="576" y="590" as="sourcePoint" />
            <mxPoint x="576" y="555" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=10;fontColor=#c2185b;fontStyle=1;" value="阈值约10000次&#xa;(可通过参数调整)" vertex="1">
          <mxGeometry height="30" width="140" x="506" y="595" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e8f5e9;strokeColor=#4caf50;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="165" width="880" x="60" y="665" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=#4caf50;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=1;fontSize=14;fontStyle=1;fontColor=#ffffff;spacingLeft=10;" value="阶段4: 高效执行" vertex="1">
          <mxGeometry height="28" width="140" x="70" y="675" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#c8e6c9;strokeColor=#4caf50;fontSize=11;fontColor=#2e7d32;" value="编译型特征" vertex="1">
          <mxGeometry height="28" width="80" x="220" y="675" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#a5d6a7;strokeColor=#4caf50;fontSize=12;fontStyle=1;" value="calculate()" vertex="1">
          <mxGeometry height="40" width="100" x="90" y="725" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4caf50;strokeColor=#2e7d32;fontColor=#ffffff;fontSize=12;fontStyle=1;" value="JIT 编译器" vertex="1">
          <mxGeometry height="40" width="100" x="240" y="725" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#c8e6c9;strokeColor=#4caf50;fontSize=11;fontStyle=1;" value="优化后的&#xa;机器码" vertex="1">
          <mxGeometry height="50" width="90" x="390" y="720" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=8;fillColor=#a5d6a7;strokeColor=#4caf50;fontSize=11;fontStyle=1;" value="Code Cache" vertex="1">
          <mxGeometry height="55" width="90" x="530" y="715" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#2e7d32;strokeColor=#1b5e20;fontColor=#ffffff;fontSize=12;fontStyle=1;" value="⚡ 原生速度" vertex="1">
          <mxGeometry height="40" width="100" x="670" y="725" as="geometry" />
        </mxCell>
        <mxCell id="45" edge="1" parent="1" source="40" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#4caf50;" target="41" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="46" edge="1" parent="1" source="41" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#4caf50;" target="42" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="47" edge="1" parent="1" source="42" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#4caf50;" target="43" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="48" edge="1" parent="1" source="43" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#4caf50;" target="44" value="">
          <mxGeometry relative="1" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#424242;spacingLeft=5;" value="• JIT 将 calculate() 编译为优化后的机器码&#xa;• 机器码缓存在 Code Cache&#xa;• 后续调用直接执行机器码,接近原生速度" vertex="1">
          <mxGeometry height="50" width="350" x="90" y="780" as="geometry" />
        </mxCell>
        <mxCell id="50" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#9e9e9e;dashed=1;" value="">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="500" y="245" as="sourcePoint" />
            <mxPoint x="500" y="265" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="51" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#9e9e9e;dashed=1;" value="">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="500" y="425" as="sourcePoint" />
            <mxPoint x="500" y="445" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="52" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#9e9e9e;dashed=1;" value="">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="500" y="645" as="sourcePoint" />
            <mxPoint x="500" y="665" as="targetPoint" />
          </mxGeometry>
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

结论

阶段 方式 语言特征
.java → .class 编译 编译型
字节码 → 解释执行 解释 解释型
热点代码 → 机器码 编译 编译型

四、JIT 即时编译器

4.1 JIT 工作原理

<mxfile>
  <diagram id="jit-compiler-principle" name="JIT 编译器工作原理">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="980" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="940" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JIT 编译器工作原理" vertex="1">
          <mxGeometry height="50" width="1040" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="⚡" vertex="1">
          <mxGeometry height="40" width="40" x="1000" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#7c3aed;strokeColor=#6d28d9;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#ffffff;" value="字节码执行" vertex="1">
          <mxGeometry height="50" width="200" x="450" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📦" vertex="1">
          <mxGeometry height="40" width="40" x="410" y="95" as="geometry" />
        </mxCell>
        <mxCell id="7" edge="1" parent="1" source="5" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#94a3b8;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="10" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="450" y="150" as="sourcePoint" />
            <mxPoint x="250" y="200" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="8" edge="1" parent="1" source="5" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#94a3b8;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="11" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="150" as="sourcePoint" />
            <mxPoint x="550" y="200" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="9" edge="1" parent="1" source="5" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#94a3b8;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="12" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="650" y="150" as="sourcePoint" />
            <mxPoint x="850" y="200" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="80" width="180" x="140" y="180" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="80" width="180" x="460" y="180" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="80" width="180" x="780" y="180" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🧊 冷代码" vertex="1">
          <mxGeometry height="28" width="140" x="160" y="190" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="(执行次数少)" vertex="1">
          <mxGeometry height="25" width="180" x="140" y="225" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🌡️ 温代码" vertex="1">
          <mxGeometry height="28" width="140" x="480" y="190" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="(执行次数中)" vertex="1">
          <mxGeometry height="25" width="180" x="460" y="225" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🔥 热代码" vertex="1">
          <mxGeometry height="28" width="140" x="800" y="190" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="(执行次数多)" vertex="1">
          <mxGeometry height="25" width="180" x="780" y="225" as="geometry" />
        </mxCell>
        <mxCell id="19" edge="1" parent="1" source="10" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#3b82f6;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="22" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="230" y="270" as="sourcePoint" />
            <mxPoint x="230" y="310" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="20" edge="1" parent="1" source="11" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#f59e0b;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="23" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="270" as="sourcePoint" />
            <mxPoint x="550" y="310" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="21" edge="1" parent="1" source="12" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#ec4899;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="24" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="870" y="270" as="sourcePoint" />
            <mxPoint x="870" y="310" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="180" x="140" y="290" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="180" x="460" y="290" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="180" x="780" y="290" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#1e40af;" value="解释执行" vertex="1">
          <mxGeometry height="25" width="180" x="140" y="300" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" value="🐢 逐行翻译" vertex="1">
          <mxGeometry height="25" width="180" x="140" y="325" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="C1 编译" vertex="1">
          <mxGeometry height="25" width="180" x="460" y="300" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#f59e0b;" value="⚡ 快速编译" vertex="1">
          <mxGeometry height="25" width="180" x="460" y="325" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#be185d;" value="C2 编译" vertex="1">
          <mxGeometry height="25" width="180" x="780" y="300" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#ec4899;" value="🚀 深度优化" vertex="1">
          <mxGeometry height="25" width="180" x="780" y="325" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="strokeWidth=3;html=1;shape=mxgraph.flowchart.annotation_2;align=left;labelPosition=right;pointerEvents=1;strokeColor=#64748b;rotation=90;" value="" vertex="1">
          <mxGeometry height="100" width="75" x="512.5" y="347.5" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="HotSpot VM 分层编译 (Tiered Compilation)" vertex="1">
          <mxGeometry height="40" width="980" x="60" y="420" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="⭐" vertex="1">
          <mxGeometry height="36" width="30" x="1000" y="422" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="460" width="980" x="60" y="480" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="90" width="900" x="100" y="510" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Level 0" vertex="1">
          <mxGeometry height="30" width="90" x="120" y="525" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#1e40af;" value="解释器执行" vertex="1">
          <mxGeometry height="30" width="120" x="230" y="525" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="🐢" vertex="1">
          <mxGeometry height="40" width="40" x="350" y="520" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="• 无需编译,立即执行" vertex="1">
          <mxGeometry height="25" width="200" x="420" y="520" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="• 收集方法调用计数" vertex="1">
          <mxGeometry height="25" width="200" x="420" y="545" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="• 收集循环回边计数" vertex="1">
          <mxGeometry height="25" width="200" x="420" y="570" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#bfdbfe;align=center;verticalAlign=middle;fontSize=12;fontColor=#1e40af;rounded=1;" value="速度: ★☆☆☆☆" vertex="1">
          <mxGeometry height="25" width="120" x="800" y="540" as="geometry" />
        </mxCell>
        <mxCell id="43" edge="1" parent="1" source="35" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#f59e0b;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="47" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="610" as="sourcePoint" />
            <mxPoint x="550" y="650" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef3c7;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;fontStyle=1;rounded=1;" value="调用次数 &gt; 阈值1" vertex="1">
          <mxGeometry height="24" width="130" x="560" y="605" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#b45309;" value="(约 1,500 次)" vertex="1">
          <mxGeometry height="24" width="90" x="690" y="605" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="120" width="900" x="100" y="640" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Level 1-3" vertex="1">
          <mxGeometry height="30" width="100" x="120" y="655" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#92400e;" value="C1 编译器 (Client Compiler)" vertex="1">
          <mxGeometry height="30" width="230" x="240" y="655" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="⚡" vertex="1">
          <mxGeometry height="40" width="40" x="470" y="650" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="• 快速编译,编译时间短" vertex="1">
          <mxGeometry height="25" width="200" x="140" y="695" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="• 简单优化(基本内联、常量折叠)" vertex="1">
          <mxGeometry height="25" width="260" x="140" y="720" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="• 收集 Profile 性能数据" vertex="1">
          <mxGeometry height="25" width="200" x="420" y="695" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" value="• 为 C2 编译提供数据支持" vertex="1">
          <mxGeometry height="25" width="220" x="420" y="720" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=#fde68a;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;rounded=1;" value="速度: ★★★☆☆" vertex="1">
          <mxGeometry height="25" width="120" x="800" y="670" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=#fde68a;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;rounded=1;" value="编译: ★★★★☆" vertex="1">
          <mxGeometry height="25" width="120" x="800" y="700" as="geometry" />
        </mxCell>
        <mxCell id="57" edge="1" parent="1" source="47" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#ec4899;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="61" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="550" y="770" as="sourcePoint" />
            <mxPoint x="550" y="810" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=#fce7f3;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;fontStyle=1;rounded=1;" value="调用次数 &gt; 阈值2 且 Profile 数据充足" vertex="1">
          <mxGeometry height="24" width="250" x="560" y="765" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#be185d;" value="(约 10,000 次)" vertex="1">
          <mxGeometry height="24" width="90" x="810" y="765" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fce7f3;strokeColor=#ec4899;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="120" width="900" x="100" y="800" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Level 4" vertex="1">
          <mxGeometry height="30" width="90" x="120" y="815" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#be185d;" value="C2 编译器 (Server Compiler)" vertex="1">
          <mxGeometry height="30" width="240" x="230" y="815" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="🚀" vertex="1">
          <mxGeometry height="40" width="40" x="470" y="810" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="• 深度优化,编译时间长" vertex="1">
          <mxGeometry height="25" width="200" x="140" y="855" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="• 方法内联 (Inlining)" vertex="1">
          <mxGeometry height="25" width="180" x="140" y="880" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="• 逃逸分析 (Escape Analysis)" vertex="1">
          <mxGeometry height="25" width="220" x="340" y="855" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="• 循环优化 (Loop Optimization)" vertex="1">
          <mxGeometry height="25" width="230" x="340" y="880" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="• 生成高度优化的机器码" vertex="1">
          <mxGeometry height="25" width="200" x="590" y="855" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#be185d;" value="• 接近 C/C++ 性能" vertex="1">
          <mxGeometry height="25" width="180" x="590" y="880" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;" value="速度: ★★★★★" vertex="1">
          <mxGeometry height="25" width="120" x="800" y="830" as="geometry" />
        </mxCell>
        <mxCell id="72" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbcfe8;align=center;verticalAlign=middle;fontSize=12;fontColor=#be185d;rounded=1;" value="编译: ★★☆☆☆" vertex="1">
          <mxGeometry height="25" width="120" x="800" y="860" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

4.2 热点探测机制

// 热点探测示例
public class HotSpotDemo {

    private static int counter = 0;

    // 这个方法会被识别为"热点方法"
    public static int hotMethod(int n) {
        return n * n;
    }

    public static void main(String[] args) {
        // 大量调用,触发 JIT 编译
        for (int i = 0; i < 100_000; i++) {
            hotMethod(i);
        }

        // 此时 hotMethod 已被 JIT 编译为机器码
        // 后续调用将直接执行机器码
        long start = System.nanoTime();
        for (int i = 0; i < 100_000; i++) {
            hotMethod(i);
        }
        long end = System.nanoTime();
        System.out.println("执行时间: " + (end - start) + " ns");
    }
}

热点探测方式

<mxfile>
  <diagram id="hotspot-detection" name="热点探测方式">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="760" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="720" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#dc2626;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="热点探测方式" vertex="1">
          <mxGeometry height="50" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="🔥" vertex="1">
          <mxGeometry height="40" width="40" x="820" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="290" width="780" x="60" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#1d4ed8;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#ffffff;" value="1" vertex="1">
          <mxGeometry height="40" width="40" x="80" y="110" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="方法调用计数器 (Invocation Counter)" vertex="1">
          <mxGeometry height="40" width="350" x="130" y="110" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="📊" vertex="1">
          <mxGeometry height="35" width="40" x="480" y="115" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#93c5fd;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="190" width="720" x="90" y="170" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=#1e40af;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="工作原理" vertex="1">
          <mxGeometry height="28" width="90" x="110" y="185" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#bfdbfe;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="120" width="280" x="110" y="228" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#1d4ed8;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" value="方法调用" vertex="1">
          <mxGeometry height="35" width="90" x="130" y="245" as="geometry" />
        </mxCell>
        <mxCell id="13" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="230" y="262" as="sourcePoint" />
            <mxPoint x="270" y="262" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#60a5fa;strokeColor=#3b82f6;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" value="计数器 +1" vertex="1">
          <mxGeometry height="35" width="90" x="280" y="245" as="geometry" />
        </mxCell>
        <mxCell id="15" edge="1" parent="1" source="14" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" target="16" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="325" y="290" as="sourcePoint" />
            <mxPoint x="325" y="320" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="16" parent="1" style="rhombus;whiteSpace=wrap;html=1;fillColor=#93c5fd;strokeColor=#3b82f6;strokeWidth=2;fontSize=12;fontStyle=1;fontColor=#1e40af;" value="超过阈值?" vertex="1">
          <mxGeometry height="40" width="90" x="200" y="295" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#166534;fontStyle=1;" value="是" vertex="1">
          <mxGeometry height="20" width="30" x="290" y="300" as="geometry" />
        </mxCell>
        <mxCell id="18" edge="1" parent="1" source="16" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#22c55e;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="290" y="315" as="sourcePoint" />
            <mxPoint x="320" y="315" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="19" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="JIT 编译" vertex="1">
          <mxGeometry height="30" width="60" x="320" y="300" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#dc2626;fontStyle=1;" value="否" vertex="1">
          <mxGeometry height="20" width="30" x="165" y="300" as="geometry" />
        </mxCell>
        <mxCell id="21" edge="1" parent="1" source="16" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#ef4444;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;curved=1;" target="12" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <Array as="points">
              <mxPoint x="120" y="315" />
              <mxPoint x="120" y="262" />
            </Array>
            <mxPoint x="200" y="315" as="sourcePoint" />
            <mxPoint x="130" y="262" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#1e40af;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="默认阈值" vertex="1">
          <mxGeometry height="28" width="90" x="420" y="185" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#bfdbfe;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="120" width="370" x="420" y="229" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef3c7;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#92400e;rounded=1;" value="Client 模式" vertex="1">
          <mxGeometry height="28" width="100" x="440" y="240" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="1,500" vertex="1">
          <mxGeometry height="28" width="80" x="555" y="240" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=#fce7f3;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#be185d;rounded=1;" value="Server 模式" vertex="1">
          <mxGeometry height="28" width="100" x="440" y="280" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="10,000" vertex="1">
          <mxGeometry height="28" width="80" x="555" y="280" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=#e2e8f0;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#475569;rounded=1;" value="⚙️ 调整参数" vertex="1">
          <mxGeometry height="22" width="90" x="440" y="320" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#1e293b;align=center;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#22c55e;rounded=1;" value="-XX:CompileThreshold=N" vertex="1">
          <mxGeometry height="26" width="220" x="540" y="318" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="次" vertex="1">
          <mxGeometry height="28" width="30" x="635" y="240" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#1e40af;" value="次" vertex="1">
          <mxGeometry height="28" width="30" x="635" y="280" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="320" width="780" x="60" y="400" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#d97706;strokeWidth=2;fontSize=18;fontStyle=1;fontColor=#ffffff;" value="2" vertex="1">
          <mxGeometry height="40" width="40" x="80" y="420" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="回边计数器 (Back Edge Counter)" vertex="1">
          <mxGeometry height="40" width="310" x="130" y="420" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="🔄" vertex="1">
          <mxGeometry height="35" width="40" x="440" y="425" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fcd34d;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="220" width="720" x="90" y="480" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#92400e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="工作原理" vertex="1">
          <mxGeometry height="28" width="90" x="110" y="495" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#92400e;" value="• 统计循环体执行次数(回边 = 循环跳转回起点)" vertex="1">
          <mxGeometry height="25" width="380" x="110" y="530" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#92400e;" value="• 用于触发 OSR (On-Stack Replacement) 编译" vertex="1">
          <mxGeometry height="25" width="380" x="110" y="555" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontColor=#92400e;" value="• 允许在方法执行过程中切换到编译后的代码" vertex="1">
          <mxGeometry height="25" width="380" x="110" y="580" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=#92400e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="代码示例" vertex="1">
          <mxGeometry height="28" width="90" x="520" y="495" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1e293b;strokeColor=#475569;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="90" width="270" x="520" y="535" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontFamily=Courier New;fontColor=#a5f3fc;" value="for (int i = 0; i &lt; 10000; i++) {" vertex="1">
          <mxGeometry height="22" width="240" x="535" y="545" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontFamily=Courier New;fontColor=#86efac;" value="    // 循环体代码" vertex="1">
          <mxGeometry height="22" width="180" x="535" y="567" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontFamily=Courier New;fontColor=#a5f3fc;" value="}" vertex="1">
          <mxGeometry height="22" width="30" x="535" y="589" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbbf24;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#78350f;rounded=1;" value="每次循环" vertex="1">
          <mxGeometry height="20" width="60" x="625" y="510" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbbf24;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#78350f;rounded=1;" value="回边计数 +1" vertex="1">
          <mxGeometry height="20" width="80" x="705" y="510" as="geometry" />
        </mxCell>
        <mxCell id="48" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#f59e0b;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="689" y="522" as="sourcePoint" />
            <mxPoint x="704" y="522" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="65" width="680" x="110" y="620" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🚀 OSR 编译触发" vertex="1">
          <mxGeometry height="28" width="140" x="121" y="637" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="当回边计数超过阈值时,JVM 会在循环执行过程中,将解释执行切换为编译后的机器码执行" vertex="1">
          <mxGeometry height="45" width="480" x="262" y="630" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="超过阈值" vertex="1">
          <mxGeometry height="20" width="60" x="625" y="591" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="触发 OSR" vertex="1">
          <mxGeometry height="20" width="70" x="705" y="591" as="geometry" />
        </mxCell>
        <mxCell id="54" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#22c55e;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="687" y="602" as="sourcePoint" />
            <mxPoint x="702" y="602" as="targetPoint" />
          </mxGeometry>
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

4.3 JIT 优化技术

方法内联 (Method Inlining)

// 优化前
public int calculate(int x) {
    return square(x) + cube(x);
}

private int square(int n) { return n * n; }
private int cube(int n) { return n * n * n; }

// JIT 优化后 (方法内联)
public int calculate(int x) {
    return (x * x) + (x * x * x);  // 直接展开,消除方法调用开销
}

逃逸分析 (Escape Analysis)

// 逃逸分析示例
public class EscapeAnalysisDemo {

    public int calculate() {
        // point 对象未逃逸出方法
        Point point = new Point(1, 2);
        return point.x + point.y;
    }

    private class Point {
        int x, y;
        Point(int x, int y) { this.x = x; this.y = y; }
    }
}

// JIT 优化后 (标量替换)
public int calculate() {
    // 对象被拆解为标量,直接在栈上分配
    int x = 1;
    int y = 2;
    return x + y;  // 可能进一步优化为 return 3;
}
<mxfile>
  <diagram id="escape-analysis" name="逃逸分析优化效果">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="680" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#8b5cf6;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="逃逸分析优化效果" vertex="1">
          <mxGeometry height="50" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="🔍" vertex="1">
          <mxGeometry height="40" width="40" x="820" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="逃逸类型" vertex="1">
          <mxGeometry height="35" width="120" x="150" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="优化方式" vertex="1">
          <mxGeometry height="35" width="120" x="390" y="90" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="优化程度" vertex="1">
          <mxGeometry height="35" width="100" x="630" y="90" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="180" width="790" x="60" y="145" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="140" x="80" y="200" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;" value="🔒 不逃逸" vertex="1">
          <mxGeometry height="25" width="140" x="80" y="210" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontColor=#dcfce7;" value="(方法内部)" vertex="1">
          <mxGeometry height="25" width="140" x="80" y="235" as="geometry" />
        </mxCell>
        <mxCell id="12" edge="1" parent="1" source="11" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#22c55e;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0;exitDx=0;exitDy=0;" target="13" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="230" y="200" as="sourcePoint" />
            <mxPoint x="280" y="200" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0fdf4;strokeColor=#86efac;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="150" width="440" x="280" y="160" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#bbf7d0;strokeColor=#4ade80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="180" x="300" y="175" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" value="📦 栈上分配" vertex="1">
          <mxGeometry height="22" width="180" x="300" y="180" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#15803d;" value="避免堆分配和 GC 开销" vertex="1">
          <mxGeometry height="22" width="180" x="300" y="202" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#bbf7d0;strokeColor=#4ade80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="200" x="500" y="175" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" value="🧩 标量替换" vertex="1">
          <mxGeometry height="22" width="200" x="500" y="180" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#15803d;" value="将对象拆解为基本类型" vertex="1">
          <mxGeometry height="22" width="200" x="500" y="202" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#bbf7d0;strokeColor=#4ade80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="50" width="400" x="300" y="245" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" value="🔓 同步消除" vertex="1">
          <mxGeometry height="22" width="100" x="310" y="255" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#15803d;" value="消除不必要的 synchronized 锁" vertex="1">
          <mxGeometry height="22" width="260" x="420" y="255" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="★★★★★" vertex="1">
          <mxGeometry height="30" width="90" x="740" y="200" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#166534;fontStyle=1;" value="完全优化" vertex="1">
          <mxGeometry height="20" width="90" x="740" y="235" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="790" x="60" y="345" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#d97706;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="140" x="80" y="365" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;" value="⚠️ 方法逃逸" vertex="1">
          <mxGeometry height="25" width="140" x="80" y="375" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#fef3c7;" value="(传递给其他方法)" vertex="1">
          <mxGeometry height="22" width="140" x="80" y="398" as="geometry" />
        </mxCell>
        <mxCell id="29" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#f59e0b;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="230" y="395" as="sourcePoint" />
            <mxPoint x="280" y="395" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="440" x="280" y="360" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="🔸 部分优化" vertex="1">
          <mxGeometry height="25" width="120" x="300" y="375" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b45309;" value="可能进行同步消除,但无法栈上分配" vertex="1">
          <mxGeometry height="25" width="270" x="430" y="375" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b45309;" value="取决于被调用方法的内联情况" vertex="1">
          <mxGeometry height="25" width="250" x="430" y="398" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="★★★☆☆" vertex="1">
          <mxGeometry height="30" width="90" x="740" y="375" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#92400e;fontStyle=1;" value="部分优化" vertex="1">
          <mxGeometry height="20" width="90" x="740" y="408" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fee2e2;strokeColor=#ef4444;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="100" width="790" x="60" y="465" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ef4444;strokeColor=#dc2626;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="60" width="140" x="80" y="485" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;" value="❌ 线程逃逸" vertex="1">
          <mxGeometry height="25" width="140" x="80" y="495" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#fecaca;" value="(被其他线程访问)" vertex="1">
          <mxGeometry height="22" width="140" x="80" y="518" as="geometry" />
        </mxCell>
        <mxCell id="40" edge="1" parent="1" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#ef4444;" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="230" y="515" as="sourcePoint" />
            <mxPoint x="280" y="515" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef2f2;strokeColor=#fca5a5;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="70" width="440" x="280" y="480" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#dc2626;" value="🚫 无法优化" vertex="1">
          <mxGeometry height="25" width="120" x="300" y="495" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b91c1c;" value="必须在堆上分配,保证线程安全" vertex="1">
          <mxGeometry height="25" width="270" x="430" y="495" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b91c1c;" value="需要保留所有同步操作" vertex="1">
          <mxGeometry height="25" width="200" x="430" y="518" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="★☆☆☆☆" vertex="1">
          <mxGeometry height="30" width="90" x="740" y="495" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#dc2626;fontStyle=1;" value="无法优化" vertex="1">
          <mxGeometry height="20" width="90" x="740" y="528" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="75" width="790" x="60" y="585" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="⚙️ 启用参数" vertex="1">
          <mxGeometry height="30" width="110" x="80" y="600" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#1e293b;align=center;verticalAlign=middle;fontSize=14;fontFamily=Courier New;fontColor=#22c55e;rounded=1;" value="-XX:+DoEscapeAnalysis" vertex="1">
          <mxGeometry height="30" width="230" x="210" y="600" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#a5b4fc;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#3730a3;rounded=1;" value="JDK 6u23+ 默认开启" vertex="1">
          <mxGeometry height="30" width="160" x="460" y="600" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="✅" vertex="1">
          <mxGeometry height="35" width="35" x="620" y="598" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=#64748b;align=center;verticalAlign=middle;fontSize=12;fontFamily=Courier New;fontColor=#f1f5f9;rounded=1;" value="关闭: -XX:-DoEscapeAnalysis" vertex="1">
          <mxGeometry height="35" width="190" x="650" y="599" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

循环优化

// 循环展开 (Loop Unrolling)
// 优化前
for (int i = 0; i < 4; i++) {
    arr[i] = i * 2;
}

// JIT 优化后
arr[0] = 0;
arr[1] = 2;
arr[2] = 4;
arr[3] = 6;

// 循环剥离 (Loop Peeling)
// 优化前
for (int i = 0; i < n; i++) {
    if (i == 0) {
        init();
    }
    process(i);
}

// JIT 优化后
init();
process(0);
for (int i = 1; i < n; i++) {
    process(i);  // 循环内不再有条件判断
}

4.4 JIT 相关 JVM 参数

# 查看 JIT 编译过程
java -XX:+PrintCompilation Demo

# 输出示例:
#  时间戳  编译ID  属性  层级  方法名
    176   1       n    0    java.lang.Object::<init> (1 bytes)
    178   2       n    0    java.lang.String::hashCode (55 bytes)
    180   3       b    3    Demo::hotMethod (6 bytes)

# 属性含义:
# n = native 方法
# s = synchronized 方法
# b = 阻塞编译
# ! = 有异常处理
# % = OSR 编译

# 常用 JIT 参数
-XX:+TieredCompilation          # 启用分层编译(默认开启)
-XX:CompileThreshold=10000      # 编译阈值
-XX:+PrintCompilation           # 打印编译信息
-XX:+UnlockDiagnosticVMOptions  # 解锁诊断选项
-XX:+PrintInlining              # 打印内联信息
-XX:+PrintAssembly              # 打印汇编代码(需要 hsdis 插件)

五、AOT 提前编译

5.1 AOT 概述

<mxfile>
  <diagram id="jit-vs-aot" name="JIT vs AOT 对比">
    <mxGraphModel dx="900" dy="750" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="750">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="840" height="710" as="geometry" />
        </mxCell>
        <mxCell id="3" value="JIT vs AOT 对比" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="840" height="50" as="geometry" />
        </mxCell>
        <mxCell id="4" value="⚡" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" vertex="1" parent="1">
          <mxGeometry x="820" y="25" width="40" height="40" as="geometry" />
        </mxCell>
        <mxCell id="5" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="50" y="90" width="800" height="290" as="geometry" />
        </mxCell>
        <mxCell id="6" value="JIT (Just-In-Time) 即时编译" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="110" width="280" height="40" as="geometry" />
        </mxCell>
        <mxCell id="7" value="🔥" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" vertex="1" parent="1">
          <mxGeometry x="350" y="115" width="35" height="35" as="geometry" />
        </mxCell>
        <mxCell id="8" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#93c5fd;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="165" width="760" height="70" as="geometry" />
        </mxCell>
        <mxCell id="9" value=".java" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fbbf24;strokeColor=#f59e0b;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#78350f;" vertex="1" parent="1">
          <mxGeometry x="90" y="180" width="70" height="40" as="geometry" />
        </mxCell>
        <mxCell id="10" value="" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="170" y="199" as="sourcePoint" />
            <mxPoint x="210" y="199" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="11" value=".class" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#a78bfa;strokeColor=#8b5cf6;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="220" y="180" width="70" height="40" as="geometry" />
        </mxCell>
        <mxCell id="12" value="" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="300" y="199" as="sourcePoint" />
            <mxPoint x="340" y="199" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="13" value="JVM 运行时" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#1d4ed8;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="350" y="175" width="120" height="50" as="geometry" />
        </mxCell>
        <mxCell id="14" value="" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#3b82f6;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="480" y="199" as="sourcePoint" />
            <mxPoint x="520" y="199" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="15" value="机器码" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="530" y="180" width="80" height="40" as="geometry" />
        </mxCell>
        <mxCell id="16" value="运行时动态编译" style="text;html=1;strokeColor=none;fillColor=#60a5fa;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="640" y="185" width="120" height="28" as="geometry" />
        </mxCell>
        <mxCell id="17" value="⏱️" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" vertex="1" parent="1">
          <mxGeometry x="760" y="182" width="30" height="30" as="geometry" />
        </mxCell>
        <mxCell id="18" value="特点" style="text;html=1;strokeColor=none;fillColor=#1e40af;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="250" width="60" height="28" as="geometry" />
        </mxCell>
        <mxCell id="19" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#fcd34d;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="290" width="180" height="70" as="geometry" />
        </mxCell>
        <mxCell id="20" value="🐢 启动慢" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="70" y="300" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="21" value="需要预热时间" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="70" y="325" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="22" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#86efac;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="265" y="290" width="180" height="70" as="geometry" />
        </mxCell>
        <mxCell id="23" value="🚀 峰值性能高" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" vertex="1" parent="1">
          <mxGeometry x="265" y="300" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="24" value="运行时充分优化" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#15803d;" vertex="1" parent="1">
          <mxGeometry x="265" y="325" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="25" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fee2e2;strokeColor=#fca5a5;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="460" y="290" width="180" height="70" as="geometry" />
        </mxCell>
        <mxCell id="26" value="💾 内存占用大" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#dc2626;" vertex="1" parent="1">
          <mxGeometry x="460" y="300" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="27" value="需要 JVM 运行时" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b91c1c;" vertex="1" parent="1">
          <mxGeometry x="460" y="325" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="28" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#e0e7ff;strokeColor=#a5b4fc;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="655" y="290" width="175" height="70" as="geometry" />
        </mxCell>
        <mxCell id="29" value="✨ 支持动态特性" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#4338ca;" vertex="1" parent="1">
          <mxGeometry x="655" y="300" width="175" height="22" as="geometry" />
        </mxCell>
        <mxCell id="30" value="反射、动态代理等" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#6366f1;" vertex="1" parent="1">
          <mxGeometry x="655" y="325" width="175" height="22" as="geometry" />
        </mxCell>
        <mxCell id="31" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="50" y="400" width="800" height="290" as="geometry" />
        </mxCell>
        <mxCell id="32" value="AOT (Ahead-Of-Time) 提前编译" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="420" width="300" height="40" as="geometry" />
        </mxCell>
        <mxCell id="33" value="📦" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" vertex="1" parent="1">
          <mxGeometry x="370" y="425" width="35" height="35" as="geometry" />
        </mxCell>
        <mxCell id="34" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="475" width="760" height="70" as="geometry" />
        </mxCell>
        <mxCell id="35" value=".java" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fbbf24;strokeColor=#f59e0b;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#78350f;" vertex="1" parent="1">
          <mxGeometry x="90" y="490" width="70" height="40" as="geometry" />
        </mxCell>
        <mxCell id="36" value="" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#f59e0b;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="170" y="509" as="sourcePoint" />
            <mxPoint x="210" y="509" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="37" value=".class" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#a78bfa;strokeColor=#8b5cf6;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="220" y="490" width="70" height="40" as="geometry" />
        </mxCell>
        <mxCell id="38" value="" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#f59e0b;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="300" y="509" as="sourcePoint" />
            <mxPoint x="340" y="509" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="39" value="编译期" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#d97706;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="350" y="485" width="100" height="50" as="geometry" />
        </mxCell>
        <mxCell id="40" value="" style="endArrow=classic;html=1;strokeWidth=2;strokeColor=#f59e0b;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="460" y="509" as="sourcePoint" />
            <mxPoint x="500" y="509" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="41" value="Native 镜像" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#16a34a;strokeWidth=2;fontSize=13;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="510" y="490" width="100" height="40" as="geometry" />
        </mxCell>
        <mxCell id="42" value="提前编译为本地代码" style="text;html=1;strokeColor=none;fillColor=#d97706;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="640" y="495" width="150" height="28" as="geometry" />
        </mxCell>
        <mxCell id="43" value="🏗️" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" vertex="1" parent="1">
          <mxGeometry x="790" y="492" width="30" height="30" as="geometry" />
        </mxCell>
        <mxCell id="44" value="特点" style="text;html=1;strokeColor=none;fillColor=#92400e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="560" width="60" height="28" as="geometry" />
        </mxCell>
        <mxCell id="45" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#86efac;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="70" y="600" width="180" height="70" as="geometry" />
        </mxCell>
        <mxCell id="46" value="🚀 启动快" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" vertex="1" parent="1">
          <mxGeometry x="70" y="610" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="47" value="无需预热" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#15803d;" vertex="1" parent="1">
          <mxGeometry x="70" y="635" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="48" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#fcd34d;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="265" y="600" width="180" height="70" as="geometry" />
        </mxCell>
        <mxCell id="49" value="📊 峰值性能一般" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="265" y="610" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="50" value="缺少运行时优化" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="265" y="635" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="51" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#86efac;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="460" y="600" width="180" height="70" as="geometry" />
        </mxCell>
        <mxCell id="52" value="💾 内存占用小" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#166534;" vertex="1" parent="1">
          <mxGeometry x="460" y="610" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="53" value="无需 JVM 运行时" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#15803d;" vertex="1" parent="1">
          <mxGeometry x="460" y="635" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="54" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fee2e2;strokeColor=#fca5a5;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="655" y="600" width="175" height="70" as="geometry" />
        </mxCell>
        <mxCell id="55" value="⚠️ 动态特性受限" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#dc2626;" vertex="1" parent="1">
          <mxGeometry x="655" y="610" width="175" height="22" as="geometry" />
        </mxCell>
        <mxCell id="56" value="反射需额外配置" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b91c1c;" vertex="1" parent="1">
          <mxGeometry x="655" y="635" width="175" height="22" as="geometry" />
        </mxCell>
        <mxCell id="57" value="VS" style="ellipse;whiteSpace=wrap;html=1;fillColor=#6366f1;strokeColor=#4f46e5;strokeWidth=3;fontSize=18;fontStyle=1;fontColor=#ffffff;" vertex="1" parent="1">
          <mxGeometry x="420" y="365" width="60" height="60" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

5.2 JIT vs AOT 详细对比

指标 JIT 即时编译 AOT 提前编译
编译时机 运行时 构建时
启动速度 慢(需预热)
峰值性能 高(可做运行时优化) 中等
内存占用 较大 较小
打包体积 较大 较小
动态特性 完全支持 受限
适用场景 长时间运行的服务 云原生/Serverless

5.3 为什么不全用 AOT?

<mxfile>
  <diagram id="aot-limitations" name="AOT 的局限性">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="900" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="890" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="AOT 的局限性" vertex="1">
          <mxGeometry height="50" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="⚠️" vertex="1">
          <mxGeometry height="40" width="40" x="820" y="25" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fee2e2;strokeColor=#ef4444;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="230" width="800" x="50" y="90" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#ef4444;strokeColor=#dc2626;strokeWidth=2;fontSize=16;fontStyle=1;fontColor=#ffffff;" value="1" vertex="1">
          <mxGeometry height="35" width="35" x="70" y="105" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#dc2626;" value="不支持 Java 动态特性" vertex="1">
          <mxGeometry height="35" width="250" x="115" y="105" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef2f2;strokeColor=#fca5a5;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="150" width="360" x="70" y="150" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=#dc2626;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🚫 受限特性" vertex="1">
          <mxGeometry height="26" width="100" x="85" y="160" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#7f1d1d;" value="• 反射 (Reflection)" vertex="1">
          <mxGeometry height="22" width="160" x="90" y="195" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#7f1d1d;" value="• 动态代理 (Dynamic Proxy)" vertex="1">
          <mxGeometry height="22" width="200" x="90" y="220" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#7f1d1d;" value="• 动态类加载" vertex="1">
          <mxGeometry height="22" width="150" x="90" y="245" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#7f1d1d;" value="• JNI (Java Native Interface)" vertex="1">
          <mxGeometry height="22" width="200" x="90" y="270" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef2f2;strokeColor=#fca5a5;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="150" width="380" x="450" y="150" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#b91c1c;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="❓ 原因分析" vertex="1">
          <mxGeometry height="26" width="100" x="465" y="160" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#7f1d1d;" value="这些特性需要在编译时就知道所有类型信息" vertex="1">
          <mxGeometry height="25" width="340" x="470" y="200" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="shape=curlyBracket;whiteSpace=wrap;html=1;rounded=1;flipH=1;labelPosition=right;verticalLabelPosition=middle;align=left;verticalAlign=middle;strokeColor=#ef4444;strokeWidth=2;size=0.5;" value="" vertex="1">
          <mxGeometry height="55" width="20" x="470" y="230" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#991b1b;" value="AOT 在运行前完成编译" vertex="1">
          <mxGeometry height="22" width="180" x="500" y="235" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#991b1b;" value="无法获取运行时信息" vertex="1">
          <mxGeometry height="22" width="180" x="500" y="260" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="280" width="800" x="50" y="340" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#d97706;strokeWidth=2;fontSize=16;fontStyle=1;fontColor=#ffffff;" value="2" vertex="1">
          <mxGeometry height="35" width="35" x="70" y="355" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#d97706;" value="影响主流框架使用" vertex="1">
          <mxGeometry height="35" width="220" x="115" y="355" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="200" width="370" x="70" y="400" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#16a34a;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🍃 Spring Framework" vertex="1">
          <mxGeometry height="28" width="170" x="85" y="412" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef9c3;align=left;verticalAlign=middle;fontSize=12;fontColor=#713f12;rounded=1;" value="@Autowired 依赖注入" vertex="1">
          <mxGeometry height="24" width="145" x="90" y="450" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="→ 反射创建对象" vertex="1">
          <mxGeometry height="24" width="120" x="245" y="450" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef9c3;align=left;verticalAlign=middle;fontSize=12;fontColor=#713f12;rounded=1;" value="AOP 切面" vertex="1">
          <mxGeometry height="24" width="80" x="90" y="482" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="→ 动态代理" vertex="1">
          <mxGeometry height="24" width="100" x="180" y="482" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef9c3;align=left;verticalAlign=middle;fontSize=12;fontColor=#713f12;rounded=1;" value="@Configuration" vertex="1">
          <mxGeometry height="24" width="105" x="90" y="514" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="→ CGLIB 动态生成配置类" vertex="1">
          <mxGeometry height="24" width="180" x="205" y="514" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="200" width="370" x="460" y="400" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#8b5cf6;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🗄️ Hibernate / JPA" vertex="1">
          <mxGeometry height="28" width="150" x="475" y="412" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef9c3;align=left;verticalAlign=middle;fontSize=12;fontColor=#713f12;rounded=1;" value="实体类增强" vertex="1">
          <mxGeometry height="24" width="85" x="480" y="455" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="→ 动态字节码生成" vertex="1">
          <mxGeometry height="24" width="140" x="575" y="455" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#fef9c3;align=left;verticalAlign=middle;fontSize=12;fontColor=#713f12;rounded=1;" value="懒加载" vertex="1">
          <mxGeometry height="24" width="60" x="480" y="490" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#92400e;" value="→ 动态代理" vertex="1">
          <mxGeometry height="24" width="100" x="550" y="490" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbbf24;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#78350f;rounded=1;" value="💡 解决方案:需要额外配置&quot;反射元数据&quot;&lt;br&gt;才能在 AOT 模式下工作" vertex="1">
          <mxGeometry height="35" width="330" x="480" y="545" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="220" width="800" x="50" y="640" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="ellipse;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#2563eb;strokeWidth=2;fontSize=16;fontStyle=1;fontColor=#ffffff;" value="3" vertex="1">
          <mxGeometry height="35" width="35" x="70" y="655" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#2563eb;" value="性能上限较低" vertex="1">
          <mxGeometry height="35" width="180" x="115" y="655" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#93c5fd;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="140" width="760" x="70" y="700" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#2563eb;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🔥 JIT 可以做的优化(AOT 无法做到)" vertex="1">
          <mxGeometry height="28" width="300" x="85" y="712" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#60a5fa;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="90" y="752" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#1e40af;" value="🎯 激进内联" vertex="1">
          <mxGeometry height="22" width="170" x="90" y="760" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#3b82f6;" value="基于实际运行数据" vertex="1">
          <mxGeometry height="22" width="170" x="90" y="785" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#60a5fa;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="275" y="752" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#1e40af;" value="🔓 去虚拟化" vertex="1">
          <mxGeometry height="22" width="170" x="275" y="760" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#3b82f6;" value="消除虚方法调用" vertex="1">
          <mxGeometry height="22" width="170" x="275" y="785" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#60a5fa;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="460" y="752" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#1e40af;" value="🔀 分支预测优化" vertex="1">
          <mxGeometry height="22" width="170" x="460" y="760" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#3b82f6;" value="代码路径优化" vertex="1">
          <mxGeometry height="22" width="170" x="460" y="785" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#60a5fa;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="70" width="170" x="645" y="752" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#1e40af;" value="📦 动态逃逸分析" vertex="1">
          <mxGeometry height="22" width="170" x="645" y="760" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#3b82f6;" value="栈上分配优化" vertex="1">
          <mxGeometry height="22" width="170" x="645" y="785" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>
// 反射示例 - AOT 需要额外配置
public class ReflectionDemo {
    public static void main(String[] args) throws Exception {
        // 运行时动态加载类 - AOT 无法预知
        Class<?> clazz = Class.forName("com.example.User");
        Object obj = clazz.getDeclaredConstructor().newInstance();

        // 动态调用方法
        Method method = clazz.getMethod("getName");
        String name = (String) method.invoke(obj);
    }
}

// 使用 GraalVM Native Image 需要提供反射配置文件
// reflect-config.json
[
  {
    "name": "com.example.User",
    "allDeclaredConstructors": true,
    "allPublicMethods": true
  }
]

5.4 GraalVM 与 Native Image

  <mxfile>
    <diagram id="graalvm-overview" name="GraalVM 概述">
      <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700" math="0" shadow="0">
        <root>
          <mxCell id="0" />
          <mxCell id="1" parent="0" />
          <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
            <mxGeometry height="660" width="880" x="10" y="30" as="geometry" />
          </mxCell>
          <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#e11d48;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="GraalVM 概述" vertex="1">
            <mxGeometry height="50" width="840" x="30" y="30" as="geometry" />
          </mxCell>
          <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" value="🚀" vertex="1">
            <mxGeometry height="40" width="40" x="800" y="35" as="geometry" />
          </mxCell>
          <mxCell id="5" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontColor=#475569;" value="GraalVM 是 Oracle 开发的高性能 JDK 发行版,支持:" vertex="1">
            <mxGeometry height="30" width="800" x="30" y="95" as="geometry" />
          </mxCell>
          <mxCell id="6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fdf2f8;strokeColor=#ec4899;strokeWidth=3;" value="" vertex="1">
            <mxGeometry height="530" width="840" x="30" y="140" as="geometry" />
          </mxCell>
          <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#f472b6;strokeWidth=2;" value="" vertex="1">
            <mxGeometry height="490" width="800" x="50" y="160" as="geometry" />
          </mxCell>
          <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#e11d48;align=center;verticalAlign=middle;fontSize=22;fontStyle=1;fontColor=#ffffff;rounded=1;" value="GraalVM" vertex="1">
            <mxGeometry height="45" width="220" x="320" y="175" as="geometry" />
          </mxCell>
          <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=20;" value="☕" vertex="1">
            <mxGeometry height="35" width="35" x="285" y="180" as="geometry" />
          </mxCell>
          <mxCell id="10" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f1f5f9;strokeColor=#94a3b8;strokeWidth=2;" value="" vertex="1">
            <mxGeometry height="280" width="720" x="70" y="240" as="geometry" />
          </mxCell>
          <mxCell id="11" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
            <mxGeometry height="240" width="330" x="90" y="260" as="geometry" />
          </mxCell>
          <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JIT 模式" vertex="1">
            <mxGeometry height="35" width="150" x="180" y="275" as="geometry" />
          </mxCell>
          <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="⚡" vertex="1">
            <mxGeometry height="30" width="35" x="145" y="278" as="geometry" />
          </mxCell>
          <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#93c5fd;strokeWidth=1;" value="" vertex="1">
            <mxGeometry height="55" width="300" x="105" y="325" as="geometry" />
          </mxCell>
          <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#1e40af;" value="Graal JIT 编译器" vertex="1">
            <mxGeometry height="22" width="300" x="105" y="330" as="geometry" />
          </mxCell>
          <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" value="(替代 C2 编译器)" vertex="1">
            <mxGeometry height="20" width="300" x="105" y="355" as="geometry" />
          </mxCell>
          <mxCell id="17" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#86efac;strokeWidth=1;" value="" vertex="1">
            <mxGeometry height="90" width="300" x="105" y="395" as="geometry" />
          </mxCell>
          <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 更好的峰值性能" vertex="1">
            <mxGeometry height="25" width="180" x="120" y="405" as="geometry" />
          </mxCell>
          <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 完整 Java 支持" vertex="1">
            <mxGeometry height="25" width="180" x="120" y="435" as="geometry" />
          </mxCell>
          <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 动态特性完全兼容" vertex="1">
            <mxGeometry height="25" width="180" x="120" y="460" as="geometry" />
          </mxCell>
          <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=2;" value="" vertex="1">
            <mxGeometry height="240" width="330" x="440" y="260" as="geometry" />
          </mxCell>
          <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="AOT 模式" vertex="1">
            <mxGeometry height="35" width="150" x="530" y="275" as="geometry" />
          </mxCell>
          <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="📦" vertex="1">
            <mxGeometry height="30" width="35" x="495" y="278" as="geometry" />
          </mxCell>
          <mxCell id="24" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=1;" value="" vertex="1">
            <mxGeometry height="55" width="300" x="455" y="325" as="geometry" />
          </mxCell>
          <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="Native Image" vertex="1">
            <mxGeometry height="22" width="300" x="455" y="330" as="geometry" />
          </mxCell>
          <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="(编译为原生可执行文件)" vertex="1">
            <mxGeometry height="20" width="300" x="455" y="355" as="geometry" />
          </mxCell>
          <mxCell id="27" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#86efac;strokeWidth=1;" value="" vertex="1">
            <mxGeometry height="90" width="300" x="455" y="395" as="geometry" />
          </mxCell>
          <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 毫秒级启动" vertex="1">
            <mxGeometry height="25" width="150" x="470" y="405" as="geometry" />
          </mxCell>
          <mxCell id="29" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 极小内存占用" vertex="1">
            <mxGeometry height="25" width="150" x="470" y="435" as="geometry" />
          </mxCell>
          <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#166534;" value="✓ 无需 JVM" vertex="1">
            <mxGeometry height="25" width="150" x="470" y="460" as="geometry" />
          </mxCell>
          <mxCell id="31" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f3e8ff;strokeColor=#a855f7;strokeWidth=2;" value="" vertex="1">
            <mxGeometry height="90" width="760" x="70" y="540" as="geometry" />
          </mxCell>
          <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=#a855f7;align=center;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🌐 多语言支持" vertex="1">
            <mxGeometry height="30" width="130" x="90" y="555" as="geometry" />
          </mxCell>
          <mxCell id="33" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ef4444;strokeColor=#dc2626;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="Java" vertex="1">
            <mxGeometry height="28" width="60" x="240" y="555" as="geometry" />
          </mxCell>
          <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#8b5cf6;strokeColor=#7c3aed;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="Kotlin" vertex="1">
            <mxGeometry height="28" width="60" x="310" y="555" as="geometry" />
          </mxCell>
          <mxCell id="35" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dc2626;strokeColor=#b91c1c;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="Scala" vertex="1">
            <mxGeometry height="28" width="60" x="380" y="555" as="geometry" />
          </mxCell>
          <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eab308;strokeColor=#ca8a04;fontSize=12;fontStyle=1;fontColor=#422006;" value="JavaScript" vertex="1">
            <mxGeometry height="28" width="80" x="450" y="555" as="geometry" />
          </mxCell>
          <mxCell id="37" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#2563eb;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="Python" vertex="1">
            <mxGeometry height="28" width="65" x="540" y="555" as="geometry" />
          </mxCell>
          <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dc2626;strokeColor=#b91c1c;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="Ruby" vertex="1">
            <mxGeometry height="28" width="55" x="615" y="555" as="geometry" />
          </mxCell>
          <mxCell id="39" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#2563eb;strokeColor=#1d4ed8;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="R" vertex="1">
            <mxGeometry height="28" width="40" x="680" y="555" as="geometry" />
          </mxCell>
          <mxCell id="40" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#64748b;strokeColor=#475569;fontSize=12;fontStyle=1;fontColor=#ffffff;" value="LLVM 语言" vertex="1">
            <mxGeometry height="28" width="80" x="730" y="555" as="geometry" />
          </mxCell>
          <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=12;fontColor=#7c3aed;fontStyle=2;" value="Truffle 框架实现跨语言互操作" vertex="1">
            <mxGeometry height="25" width="540" x="240" y="595" as="geometry" />
          </mxCell>
        </root>
      </mxGraphModel>
    </diagram>
  </mxfile>

Native Image 构建示例

# 安装 GraalVM 和 Native Image
sdk install java 21-graalce
gu install native-image

# 编译 Java 代码为原生可执行文件
native-image -jar myapp.jar myapp

# 运行原生镜像
./myapp

# 对比启动时间
# JVM 模式: java -jar myapp.jar   → 约 1-3 秒
# Native 模式: ./myapp            → 约 10-50 毫秒

Spring Boot 3 Native 支持

<!-- pom.xml -->
<plugin>
    <groupId>org.graalvm.buildtools</groupId>
    <artifactId>native-maven-plugin</artifactId>
</plugin>
# 构建 Spring Boot Native 镜像
mvn -Pnative native:compile

# 或使用 Buildpacks
mvn spring-boot:build-image -Pnative

5.5 AOT 适用场景

<mxfile>
  <diagram id="jit-vs-aot-choice" name="选择 JIT 还是 AOT">
    <mxGraphModel dx="900" dy="750" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="750">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="840" height="710" as="geometry" />
        </mxCell>
        <mxCell id="3" value="选择 JIT 还是 AOT?" style="text;html=1;strokeColor=none;fillColor=#7c3aed;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="840" height="55" as="geometry" />
        </mxCell>
        <mxCell id="4" value="🤔" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=24;" vertex="1" parent="1">
          <mxGeometry x="815" y="28" width="45" height="40" as="geometry" />
        </mxCell>
        <mxCell id="5" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=3;" vertex="1" parent="1">
          <mxGeometry x="50" y="95" width="800" height="290" as="geometry" />
        </mxCell>
        <mxCell id="6" value="选择 JIT (传统 JVM)" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="110" width="250" height="40" as="geometry" />
        </mxCell>
        <mxCell id="7" value="⚡" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" vertex="1" parent="1">
          <mxGeometry x="320" y="115" width="35" height="30" as="geometry" />
        </mxCell>
        <mxCell id="8" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#93c5fd;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="165" width="760" height="200" as="geometry" />
        </mxCell>
        <mxCell id="9" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#60a5fa;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="180" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="10" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="100" y="192" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="11" value="长时间运行的服务" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="135" y="185" width="160" height="22" as="geometry" />
        </mxCell>
        <mxCell id="12" value="Web 服务、微服务" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" vertex="1" parent="1">
          <mxGeometry x="135" y="207" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="13" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#60a5fa;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="460" y="180" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="14" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="192" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="15" value="需要极致峰值性能" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="505" y="185" width="160" height="22" as="geometry" />
        </mxCell>
        <mxCell id="16" value="JIT 运行时优化更强" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" vertex="1" parent="1">
          <mxGeometry x="505" y="207" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="17" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#60a5fa;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="245" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="18" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="100" y="257" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="19" value="大量使用反射、动态代理" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="135" y="250" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="20" value="AOT 对动态特性支持有限" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" vertex="1" parent="1">
          <mxGeometry x="135" y="272" width="180" height="20" as="geometry" />
        </mxCell>
        <mxCell id="21" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#60a5fa;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="460" y="245" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="22" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="257" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="23" value="使用传统 Spring、Hibernate" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="505" y="250" width="230" height="22" as="geometry" />
        </mxCell>
        <mxCell id="24" value="这些框架依赖动态特性" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" vertex="1" parent="1">
          <mxGeometry x="505" y="272" width="180" height="20" as="geometry" />
        </mxCell>
        <mxCell id="25" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#60a5fa;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="310" width="350" height="40" as="geometry" />
        </mxCell>
        <mxCell id="26" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="100" y="316" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="27" value="开发调试阶段" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#1e40af;" vertex="1" parent="1">
          <mxGeometry x="135" y="319" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="28" value="🔧 快速迭代、热部署" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#3b82f6;" vertex="1" parent="1">
          <mxGeometry x="280" y="319" width="150" height="22" as="geometry" />
        </mxCell>
        <mxCell id="29" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=3;" vertex="1" parent="1">
          <mxGeometry x="50" y="405" width="800" height="305" as="geometry" />
        </mxCell>
        <mxCell id="30" value="选择 AOT (Native Image)" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=20;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="420" width="280" height="40" as="geometry" />
        </mxCell>
        <mxCell id="31" value="🚀" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=22;" vertex="1" parent="1">
          <mxGeometry x="350" y="425" width="35" height="30" as="geometry" />
        </mxCell>
        <mxCell id="32" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="70" y="475" width="760" height="215" as="geometry" />
        </mxCell>
        <mxCell id="33" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fbbf24;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="490" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="34" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="100" y="502" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="35" value="Serverless / FaaS 函数" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="135" y="495" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="36" value="启动速度关键" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="135" y="517" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="37" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fbbf24;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="460" y="490" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="38" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="502" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="39" value="CLI 命令行工具" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="505" y="495" width="160" height="22" as="geometry" />
        </mxCell>
        <mxCell id="40" value="即时响应,无预热" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="505" y="517" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="41" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fbbf24;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="555" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="42" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="100" y="567" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="43" value="微服务(频繁扩缩容)" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="135" y="560" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="44" value="快速弹性伸缩" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="135" y="582" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="45" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fbbf24;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="460" y="555" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="46" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="567" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="47" value="容器化部署" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="505" y="560" width="160" height="22" as="geometry" />
        </mxCell>
        <mxCell id="48" value="镜像体积重要" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="505" y="582" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="49" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fbbf24;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="90" y="620" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="50" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="100" y="632" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="51" value="边缘计算 / IoT" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="135" y="625" width="160" height="22" as="geometry" />
        </mxCell>
        <mxCell id="52" value="资源受限环境" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="135" y="647" width="150" height="20" as="geometry" />
        </mxCell>
        <mxCell id="53" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fbbf24;strokeWidth=1;" vertex="1" parent="1">
          <mxGeometry x="460" y="620" width="350" height="55" as="geometry" />
        </mxCell>
        <mxCell id="54" value="✓" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="470" y="632" width="28" height="28" as="geometry" />
        </mxCell>
        <mxCell id="55" value="使用 AOT 友好框架" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="505" y="625" width="180" height="22" as="geometry" />
        </mxCell>
        <mxCell id="56" value="Quarkus / Micronaut" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="505" y="647" width="150" height="20" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

六、Oracle JDK 与 OpenJDK

6.1 发展历史

<mxfile>
  <diagram id="jdk-history-timeline" name="JDK 发展历史线">
    <mxGraphModel dx="900" dy="900" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="900">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="840" height="860" as="geometry" />
        </mxCell>
        <mxCell id="3" value="JDK 发展历史线" style="text;html=1;strokeColor=none;fillColor=#0ea5e9;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="30" y="20" width="840" height="55" as="geometry" />
        </mxCell>
        <mxCell id="4" value="📜" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=24;" vertex="1" parent="1">
          <mxGeometry x="815" y="28" width="45" height="40" as="geometry" />
        </mxCell>
        <mxCell id="5" value="" style="endArrow=classic;html=1;strokeWidth=4;strokeColor=#0ea5e9;endSize=10;" edge="1" parent="1">
          <mxGeometry width="50" height="50" relative="1" as="geometry">
            <mxPoint x="120" y="110" as="sourcePoint" />
            <mxPoint x="120" y="840" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="6" value="1995" style="text;html=1;strokeColor=none;fillColor=#dc2626;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="105" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="7" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="112" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="8" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef2f2;strokeColor=#dc2626;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="95" width="690" height="50" as="geometry" />
        </mxCell>
        <mxCell id="9" value="☕ Sun 公司发布 Java" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#dc2626;" vertex="1" parent="1">
          <mxGeometry x="180" y="105" width="300" height="30" as="geometry" />
        </mxCell>
        <mxCell id="10" value="2006" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="195" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="11" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="202" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="12" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#f59e0b;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="175" width="690" height="90" as="geometry" />
        </mxCell>
        <mxCell id="13" value="🔓 Sun 开源 Java,创建 OpenJDK 项目" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#b45309;" vertex="1" parent="1">
          <mxGeometry x="180" y="182" width="400" height="28" as="geometry" />
        </mxCell>
        <mxCell id="14" value="• 基于 GPL v2 + Classpath Exception 协议" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="190" y="210" width="320" height="22" as="geometry" />
        </mxCell>
        <mxCell id="15" value="• 社区驱动开发" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#92400e;" vertex="1" parent="1">
          <mxGeometry x="190" y="232" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="16" value="2009" style="text;html=1;strokeColor=none;fillColor=#8b5cf6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="315" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="17" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="322" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="18" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f3e8ff;strokeColor=#8b5cf6;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="290" width="690" height="110" as="geometry" />
        </mxCell>
        <mxCell id="19" value="🏢 Oracle 收购 Sun" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#7c3aed;" vertex="1" parent="1">
          <mxGeometry x="180" y="298" width="250" height="28" as="geometry" />
        </mxCell>
        <mxCell id="20" value="• 获得 Java 商标和技术" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#6b21a8;" vertex="1" parent="1">
          <mxGeometry x="190" y="326" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="21" value="• 继续维护 OpenJDK" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#6b21a8;" vertex="1" parent="1">
          <mxGeometry x="190" y="348" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="22" value="• 推出商业版 Oracle JDK" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#6b21a8;" vertex="1" parent="1">
          <mxGeometry x="190" y="370" width="200" height="22" as="geometry" />
        </mxCell>
        <mxCell id="23" value="2017" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="445" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="24" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="452" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="25" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="425" width="690" height="55" as="geometry" />
        </mxCell>
        <mxCell id="26" value="🔄 Java 9 发布,开启 6 个月发布周期" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#16a34a;" vertex="1" parent="1">
          <mxGeometry x="180" y="438" width="400" height="28" as="geometry" />
        </mxCell>
        <mxCell id="27" value="2018" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="535" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="28" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="542" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="29" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef2f2;strokeColor=#ef4444;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="510" width="690" height="90" as="geometry" />
        </mxCell>
        <mxCell id="30" value="⚠️ Oracle JDK 许可证变更" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#dc2626;" vertex="1" parent="1">
          <mxGeometry x="180" y="518" width="300" height="28" as="geometry" />
        </mxCell>
        <mxCell id="31" value="• JDK 11+ 商业使用需付费" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b91c1c;" vertex="1" parent="1">
          <mxGeometry x="190" y="546" width="220" height="22" as="geometry" />
        </mxCell>
        <mxCell id="32" value="• 将 Oracle JDK 独有功能开源给 OpenJDK" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#b91c1c;" vertex="1" parent="1">
          <mxGeometry x="190" y="568" width="320" height="22" as="geometry" />
        </mxCell>
        <mxCell id="33" value="2019" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="650" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="34" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="657" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="35" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="625" width="690" height="90" as="geometry" />
        </mxCell>
        <mxCell id="36" value="🔀 功能基本一致" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#2563eb;" vertex="1" parent="1">
          <mxGeometry x="180" y="633" width="200" height="28" as="geometry" />
        </mxCell>
        <mxCell id="37" value="• JFR (Java Flight Recorder) 开源" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1d4ed8;" vertex="1" parent="1">
          <mxGeometry x="190" y="661" width="280" height="22" as="geometry" />
        </mxCell>
        <mxCell id="38" value="• JMC (Java Mission Control) 开源" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#1d4ed8;" vertex="1" parent="1">
          <mxGeometry x="190" y="683" width="280" height="22" as="geometry" />
        </mxCell>
        <mxCell id="39" value="2021" style="text;html=1;strokeColor=none;fillColor=#10b981;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="50" y="770" width="70" height="35" as="geometry" />
        </mxCell>
        <mxCell id="40" value="" style="ellipse;whiteSpace=wrap;html=1;fillColor=#0ea5e9;strokeColor=#0284c7;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="110" y="777" width="20" height="20" as="geometry" />
        </mxCell>
        <mxCell id="41" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#d1fae5;strokeColor=#10b981;strokeWidth=2;" vertex="1" parent="1">
          <mxGeometry x="160" y="745" width="690" height="110" as="geometry" />
        </mxCell>
        <mxCell id="42" value="🎉 Oracle JDK 17 免费许可" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#059669;" vertex="1" parent="1">
          <mxGeometry x="180" y="753" width="300" height="28" as="geometry" />
        </mxCell>
        <mxCell id="43" value="• NFTC 协议:允许免费商业使用" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#047857;" vertex="1" parent="1">
          <mxGeometry x="190" y="781" width="280" height="22" as="geometry" />
        </mxCell>
        <mxCell id="44" value="• 但仅限该版本发布后的 3 年内" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#047857;" vertex="1" parent="1">
          <mxGeometry x="190" y="803" width="280" height="22" as="geometry" />
        </mxCell>
        <mxCell id="45" value="⏰" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" vertex="1" parent="1">
          <mxGeometry x="470" y="800" width="30" height="25" as="geometry" />
        </mxCell>
        <mxCell id="46" value="LTS" style="text;html=1;strokeColor=none;fillColor=#10b981;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" vertex="1" parent="1">
          <mxGeometry x="500" y="803" width="40" height="20" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

6.2 主要区别对比

<mxfile>
  <diagram id="oracle-vs-openjdk" name="Oracle JDK vs OpenJDK 对比">
    <mxGraphModel dx="900" dy="600" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="700" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="Oracle JDK vs OpenJDK 对比" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=20;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="40" y="30" width="820" height="40" as="geometry" />
        </mxCell>
        <mxCell id="3" value="对比项" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#2D4059;strokeColor=#1a1a1a;fontColor=#ffffff;fontStyle=1;fontSize=14;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="90" width="180" height="50" as="geometry" />
        </mxCell>
        <mxCell id="4" value="Oracle JDK" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#C84B31;strokeColor=#1a1a1a;fontColor=#ffffff;fontStyle=1;fontSize=14;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="90" width="320" height="50" as="geometry" />
        </mxCell>
        <mxCell id="5" value="OpenJDK" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#346751;strokeColor=#1a1a1a;fontColor=#ffffff;fontStyle=1;fontSize=14;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="90" width="320" height="50" as="geometry" />
        </mxCell>
        <mxCell id="6" value="开源协议" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontStyle=1;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="140" width="180" height="60" as="geometry" />
        </mxCell>
        <mxCell id="7" value="BCL/OTN/NFTC&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(部分闭源)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FDEBD0;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="140" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="8" value="GPL v2 + CE&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(完全开源)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5F5E3;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="140" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="9" value="商业使用费用" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontStyle=1;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="200" width="180" height="80" as="geometry" />
        </mxCell>
        <mxCell id="10" value="JDK 8u211+ 收费&lt;br&gt;JDK 11-16 收费&lt;br&gt;JDK 17+ 3年免费" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FDEBD0;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="200" width="320" height="80" as="geometry" />
        </mxCell>
        <mxCell id="11" value="完全免费" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5F5E3;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="200" width="320" height="80" as="geometry" />
        </mxCell>
        <mxCell id="12" value="LTS 支持周期" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontStyle=1;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="280" width="180" height="60" as="geometry" />
        </mxCell>
        <mxCell id="13" value="8+ 年" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FDEBD0;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="280" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="14" value="无官方 LTS&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(第三方提供)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5F5E3;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="280" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="15" value="功能特性" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontStyle=1;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="340" width="180" height="60" as="geometry" />
        </mxCell>
        <mxCell id="16" value="JDK 11 后基本一致&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(早期有独占功能)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FDEBD0;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="340" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="17" value="JDK 11 后基本一致" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5F5E3;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="340" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="18" value="技术支持" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontStyle=1;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="400" width="180" height="60" as="geometry" />
        </mxCell>
        <mxCell id="19" value="Oracle 官方支持&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(付费)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FDEBD0;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="400" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="20" value="社区支持" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5F5E3;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="400" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="21" value="更新频率" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#E8E8E8;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontStyle=1;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="40" y="460" width="180" height="60" as="geometry" />
        </mxCell>
        <mxCell id="22" value="每季度&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(仅支持最新版本)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FDEBD0;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="220" y="460" width="320" height="60" as="geometry" />
        </mxCell>
        <mxCell id="23" value="每季度&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(第三方持续更新旧版)&lt;/font&gt;" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#D5F5E3;strokeColor=#1a1a1a;fontColor=#1a1a1a;fontSize=12;verticalAlign=middle;" vertex="1" parent="1">
          <mxGeometry x="540" y="460" width="320" height="60" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

6.3 JDK 发行版生态

<mxfile>
  <diagram id="jdk-distributions" name="主流 JDK 发行版">
    <mxGraphModel dx="900" dy="750" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="800" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" value="主流 JDK 发行版" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=22;fontStyle=1;fontColor=#1a1a1a;" vertex="1" parent="1">
          <mxGeometry x="40" y="20" width="820" height="40" as="geometry" />
        </mxCell>
        <mxCell id="3" value="OpenJDK&lt;br&gt;&lt;font style=&quot;font-size: 11px;&quot;&gt;(上游源码)&lt;/font&gt;" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4A90D9;strokeColor=#2171B5;fontColor=#ffffff;fontStyle=1;fontSize=14;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="370" y="80" width="160" height="60" as="geometry" />
        </mxCell>
        <mxCell id="4" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;strokeColor=#666666;strokeWidth=2;endArrow=none;endFill=0;" edge="1" parent="1" source="3">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="450" y="180" as="targetPoint" /></mxGeometry>
        </mxCell>
        <mxCell id="5" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#666666;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="450" y="180" as="sourcePoint" />
            <mxPoint x="450" y="210" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="6" value="" style="endArrow=none;html=1;strokeColor=#666666;strokeWidth=2;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="90" y="180" as="sourcePoint" />
            <mxPoint x="810" y="180" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="7" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#666666;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="90" y="180" as="sourcePoint" />
            <mxPoint x="90" y="210" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="8" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#666666;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="270" y="180" as="sourcePoint" />
            <mxPoint x="270" y="210" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="9" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#666666;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="630" y="180" as="sourcePoint" />
            <mxPoint x="630" y="210" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="10" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#666666;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="810" y="180" as="sourcePoint" />
            <mxPoint x="810" y="210" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="11" value="Oracle&lt;br&gt;JDK" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#C84B31;strokeColor=#A13A24;fontColor=#ffffff;fontStyle=1;fontSize=13;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="20" y="210" width="140" height="55" as="geometry" />
        </mxCell>
        <mxCell id="12" value="Adoptium&lt;br&gt;Temurin" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#6B5B95;strokeColor=#554785;fontColor=#ffffff;fontStyle=1;fontSize=13;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="200" y="210" width="140" height="55" as="geometry" />
        </mxCell>
        <mxCell id="13" value="Amazon&lt;br&gt;Corretto" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FF9900;strokeColor=#CC7A00;fontColor=#ffffff;fontStyle=1;fontSize=13;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="380" y="210" width="140" height="55" as="geometry" />
        </mxCell>
        <mxCell id="14" value="Azul&lt;br&gt;Zulu" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#0077B5;strokeColor=#005E8C;fontColor=#ffffff;fontStyle=1;fontSize=13;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="560" y="210" width="140" height="55" as="geometry" />
        </mxCell>
        <mxCell id="15" value="Alibaba&lt;br&gt;Dragonwell" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#FF6A00;strokeColor=#CC5500;fontColor=#ffffff;fontStyle=1;fontSize=13;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="740" y="210" width="140" height="55" as="geometry" />
        </mxCell>
        <mxCell id="16" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#C84B31;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="90" y="265" as="sourcePoint" />
            <mxPoint x="90" y="300" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="17" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#6B5B95;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="270" y="265" as="sourcePoint" />
            <mxPoint x="270" y="300" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="18" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#FF9900;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="450" y="265" as="sourcePoint" />
            <mxPoint x="450" y="300" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="19" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#0077B5;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="630" y="265" as="sourcePoint" />
            <mxPoint x="630" y="300" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="20" value="" style="shape=flexArrow;endArrow=classic;html=1;strokeColor=none;fillColor=#FF6A00;width=8;endSize=5;endWidth=12;" edge="1" parent="1">
          <mxGeometry relative="1" as="geometry">
            <mxPoint x="810" y="265" as="sourcePoint" />
            <mxPoint x="810" y="300" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="21" value="发行版详情" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;fontStyle=1;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="40" y="305" width="820" height="30" as="geometry" />
        </mxCell>
        <mxCell id="22" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=#CCCCCC;shadow=1;" vertex="1" parent="1">
          <mxGeometry x="40" y="340" width="820" height="380" as="geometry" />
        </mxCell>
        <mxCell id="23" value="Oracle JDK" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#C84B31;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="360" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="24" value="官方版本,商业支持,部分版本收费" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="360" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="25" value="Adoptium Temurin" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#6B5B95;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="405" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="26" value="Eclipse 基金会,社区维护,LTS 支持" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="405" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="27" value="Amazon Corretto" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FF9900;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="450" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="28" value="AWS 优化,长期支持,免费" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="450" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="29" value="Azul Zulu" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#0077B5;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="495" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="30" value="Azul 公司,有免费版和企业版" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="495" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="31" value="Alibaba Dragonwell" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#FF6A00;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="540" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="32" value="阿里定制,针对电商场景优化" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="540" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="33" value="Microsoft OpenJDK" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#00A4EF;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="585" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="34" value="微软维护,Azure 优化" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="585" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="35" value="IBM Semeru" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#054ADA;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="630" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="36" value="IBM 维护,OpenJ9 虚拟机" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="630" width="640" height="35" as="geometry" />
        </mxCell>
        <mxCell id="37" value="BellSoft Liberica" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#2ECC71;strokeColor=none;fontColor=#ffffff;fontStyle=1;fontSize=12;align=left;spacingLeft=10;" vertex="1" parent="1">
          <mxGeometry x="60" y="675" width="130" height="35" as="geometry" />
        </mxCell>
        <mxCell id="38" value="支持多种 CPU 架构" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=12;fontColor=#333333;" vertex="1" parent="1">
          <mxGeometry x="200" y="675" width="640" height="35" as="geometry" />
        </mxCell></root>
    </mxGraphModel>
  </diagram>
</mxfile>

6.4 如何选择 JDK

<mxfile>
  <diagram id="jdk-selection-guide" name="JDK 选择指南">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="1100" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8fafc;strokeColor=#64748b;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="980" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=26;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 选择指南" vertex="1">
          <mxGeometry height="60" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=28;" value="📋" vertex="1">
          <mxGeometry height="45" width="50" x="810" y="30" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dbeafe;strokeColor=#3b82f6;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="160" width="800" x="50" y="100" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="👤 个人学习/开发" vertex="1">
          <mxGeometry height="38" width="200" x="70" y="115" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#eff6ff;strokeColor=#93c5fd;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="80" width="760" x="70" y="165" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="推荐" vertex="1">
          <mxGeometry height="22" width="45" x="85" y="175" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#1e40af;" value="Oracle JDK 或 Adoptium Temurin" vertex="1">
          <mxGeometry height="28" width="320" x="140" y="172" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#3b82f6;" value="✓ 下载方便" vertex="1">
          <mxGeometry height="22" width="120" x="95" y="205" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#3b82f6;" value="✓ 个人使用免费" vertex="1">
          <mxGeometry height="22" width="140" x="240" y="205" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#3b82f6;" value="✓ 与生产环境保持一致" vertex="1">
          <mxGeometry height="22" width="180" x="410" y="205" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef3c7;strokeColor=#f59e0b;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="420" width="800" x="50" y="280" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🏢 企业生产环境" vertex="1">
          <mxGeometry height="38" width="200" x="70" y="295" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fcd34d;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="115" width="370" x="70" y="345" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="方案 1" vertex="1">
          <mxGeometry height="20" width="50" x="85" y="355" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="推荐" vertex="1">
          <mxGeometry height="20" width="40" x="140" y="355" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="Adoptium Temurin" vertex="1">
          <mxGeometry height="26" width="180" x="190" y="352" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 完全免费" vertex="1">
          <mxGeometry height="20" width="100" x="95" y="385" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 社区活跃" vertex="1">
          <mxGeometry height="20" width="100" x="95" y="408" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ LTS 版本支持" vertex="1">
          <mxGeometry height="20" width="130" x="95" y="431" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fcd34d;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="115" width="370" x="460" y="345" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="方案 2" vertex="1">
          <mxGeometry height="20" width="50" x="475" y="355" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="text;html=1;strokeColor=none;fillColor=#f97316;align=center;verticalAlign=middle;fontSize=10;fontStyle=0;fontColor=#ffffff;rounded=1;" value="AWS 用户" vertex="1">
          <mxGeometry height="20" width="65" x="530" y="355" as="geometry" />
        </mxCell>
        <mxCell id="25" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="Amazon Corretto" vertex="1">
          <mxGeometry height="26" width="180" x="605" y="352" as="geometry" />
        </mxCell>
        <mxCell id="26" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 完全免费" vertex="1">
          <mxGeometry height="20" width="100" x="485" y="385" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ AWS 官方支持" vertex="1">
          <mxGeometry height="20" width="140" x="485" y="408" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 长期维护承诺" vertex="1">
          <mxGeometry height="20" width="130" x="485" y="431" as="geometry" />
        </mxCell>
        <mxCell id="29" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fcd34d;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="115" width="370" x="70" y="475" as="geometry" />
        </mxCell>
        <mxCell id="30" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="方案 3" vertex="1">
          <mxGeometry height="20" width="50" x="85" y="485" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=#f97316;align=center;verticalAlign=middle;fontSize=10;fontStyle=0;fontColor=#ffffff;rounded=1;" value="阿里云用户" vertex="1">
          <mxGeometry height="20" width="70" x="140" y="485" as="geometry" />
        </mxCell>
        <mxCell id="32" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="Alibaba Dragonwell" vertex="1">
          <mxGeometry height="26" width="180" x="220" y="482" as="geometry" />
        </mxCell>
        <mxCell id="33" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 完全免费" vertex="1">
          <mxGeometry height="20" width="100" x="95" y="515" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 针对大规模集群优化" vertex="1">
          <mxGeometry height="20" width="170" x="95" y="538" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 中文社区支持" vertex="1">
          <mxGeometry height="20" width="130" x="95" y="561" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#fcd34d;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="115" width="370" x="460" y="475" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="方案 4" vertex="1">
          <mxGeometry height="20" width="50" x="475" y="485" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="text;html=1;strokeColor=none;fillColor=#64748b;align=center;verticalAlign=middle;fontSize=10;fontStyle=0;fontColor=#ffffff;rounded=1;" value="需要官方支持" vertex="1">
          <mxGeometry height="20" width="85" x="530" y="485" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=15;fontStyle=1;fontColor=#92400e;" value="Oracle JDK" vertex="1">
          <mxGeometry height="26" width="150" x="625" y="482" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#b45309;" value="✓ 有商业支持" vertex="1">
          <mxGeometry height="20" width="120" x="485" y="515" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#dc2626;" value="⚠ 需付费" vertex="1">
          <mxGeometry height="20" width="100" x="485" y="538" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fffbeb;strokeColor=#fcd34d;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="55" width="760" x="70" y="605" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=18;" value="💡" vertex="1">
          <mxGeometry height="30" width="30" x="85" y="617" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontStyle=2;fontColor=#92400e;" value="提示:所有发行版功能基本一致,主要区别在于支持策略和许可证" vertex="1">
          <mxGeometry height="30" width="500" x="120" y="617" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dcfce7;strokeColor=#22c55e;strokeWidth=3;" value="" vertex="1">
          <mxGeometry height="230" width="800" x="50" y="720" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=#10b981;align=center;verticalAlign=middle;fontSize=18;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📦 版本选择" vertex="1">
          <mxGeometry height="38" width="150" x="70" y="735" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f0fdf4;strokeColor=#86efac;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="150" width="760" x="70" y="785" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#4ade80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="230" x="90" y="800" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🆕 新项目" vertex="1">
          <mxGeometry height="22" width="75" x="100" y="808" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#166534;" value="优先选择 JDK 21" vertex="1">
          <mxGeometry height="24" width="130" x="180" y="806" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=#a855f7;align=center;verticalAlign=middle;fontSize=10;fontStyle=1;fontColor=#ffffff;rounded=1;" value="最新 LTS" vertex="1">
          <mxGeometry height="18" width="60" x="100" y="832" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#4ade80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="230" x="340" y="800" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📁 现有项目" vertex="1">
          <mxGeometry height="22" width="85" x="350" y="808" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#166534;" value="JDK 17 或 JDK 11" vertex="1">
          <mxGeometry height="24" width="130" x="440" y="806" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=10;fontStyle=1;fontColor=#ffffff;rounded=1;" value="主流 LTS" vertex="1">
          <mxGeometry height="18" width="60" x="350" y="832" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="text;html=1;strokeColor=none;fillColor=#64748b;align=center;verticalAlign=middle;fontSize=10;fontStyle=1;fontColor=#ffffff;rounded=1;" value="老项目" vertex="1">
          <mxGeometry height="18" width="50" x="415" y="832" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#4ade80;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="55" width="220" x="590" y="800" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=#64748b;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🏛️ 遗留系统" vertex="1">
          <mxGeometry height="22" width="90" x="600" y="808" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#166534;" value="JDK 8" vertex="1">
          <mxGeometry height="24" width="60" x="700" y="806" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#dc2626;" value="⚠️ 注意许可证问题" vertex="1">
          <mxGeometry height="18" width="140" x="600" y="832" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#fef2f2;strokeColor=#fca5a5;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="55" width="720" x="90" y="865" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;" value="⚠️" vertex="1">
          <mxGeometry height="28" width="30" x="100" y="878" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#dc2626;" value="重要提示:JDK 8 的 Oracle JDK 商业使用需付费,建议使用 Adoptium Temurin 8 或 Corretto 8" vertex="1">
          <mxGeometry height="28" width="660" x="130" y="878" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>

七、总结

<mxfile>
  <diagram id="jvm-core-summary" name="JVM 与运行机制 - 核心要点">
    <mxGraphModel dx="1281" dy="581" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="900" pageHeight="900" math="0" shadow="0">
      <root>
        <mxCell id="0" />
        <mxCell id="1" parent="0" />
        <mxCell id="2" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1e293b;strokeColor=#475569;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="890" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="3" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=24;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JVM 与运行机制 - 核心要点" vertex="1">
          <mxGeometry height="55" width="840" x="30" y="20" as="geometry" />
        </mxCell>
        <mxCell id="4" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=26;" value="☕" vertex="1">
          <mxGeometry height="42" width="45" x="815" y="27" as="geometry" />
        </mxCell>
        <mxCell id="5" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#312e81;strokeColor=#6366f1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="180" width="400" x="50" y="95" as="geometry" />
        </mxCell>
        <mxCell id="6" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🔧 三者关系" vertex="1">
          <mxGeometry height="32" width="130" x="65" y="108" as="geometry" />
        </mxCell>
        <mxCell id="7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#4338ca;strokeColor=#818cf8;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="110" width="360" x="70" y="150" as="geometry" />
        </mxCell>
        <mxCell id="8" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK" vertex="1">
          <mxGeometry height="24" width="50" x="90" y="160" as="geometry" />
        </mxCell>
        <mxCell id="9" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#e0e7ff;" value="= JRE + 开发工具" vertex="1">
          <mxGeometry height="24" width="150" x="150" y="160" as="geometry" />
        </mxCell>
        <mxCell id="10" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JRE" vertex="1">
          <mxGeometry height="24" width="50" x="90" y="192" as="geometry" />
        </mxCell>
        <mxCell id="11" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#e0e7ff;" value="= JVM + 核心类库" vertex="1">
          <mxGeometry height="24" width="150" x="150" y="192" as="geometry" />
        </mxCell>
        <mxCell id="12" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JVM" vertex="1">
          <mxGeometry height="24" width="50" x="90" y="224" as="geometry" />
        </mxCell>
        <mxCell id="13" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#e0e7ff;" value="= 类加载器 + 执行引擎 + 运行时数据区" vertex="1">
          <mxGeometry height="24" width="270" x="150" y="224" as="geometry" />
        </mxCell>
        <mxCell id="14" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#164e63;strokeColor=#22d3d1;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="180" width="400" x="470" y="95" as="geometry" />
        </mxCell>
        <mxCell id="15" parent="1" style="text;html=1;strokeColor=none;fillColor=#06b6d4;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📝 字节码" vertex="1">
          <mxGeometry height="32" width="110" x="485" y="108" as="geometry" />
        </mxCell>
        <mxCell id="16" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#0e7490;strokeColor=#67e8f9;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="110" width="360" x="490" y="150" as="geometry" />
        </mxCell>
        <mxCell id="17" parent="1" style="text;html=1;strokeColor=none;fillColor=#0891b2;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value=".class" vertex="1">
          <mxGeometry height="22" width="55" x="505" y="162" as="geometry" />
        </mxCell>
        <mxCell id="18" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#cffafe;" value="文件是 JVM 的&quot;语言&quot;" vertex="1">
          <mxGeometry height="24" width="180" x="565" y="160" as="geometry" />
        </mxCell>
        <mxCell id="19" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#cffafe;" value="• 平台无关的中间代码" vertex="1">
          <mxGeometry height="24" width="180" x="505" y="192" as="geometry" />
        </mxCell>
        <mxCell id="20" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#cffafe;" value="• 使用 javap -v 可查看字节码详情" vertex="1">
          <mxGeometry height="24" width="260" x="505" y="222" as="geometry" />
        </mxCell>
        <mxCell id="21" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#14532d;strokeColor=#22c55e;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="200" width="820" x="50" y="295" as="geometry" />
        </mxCell>
        <mxCell id="22" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="⚡ 执行机制" vertex="1">
          <mxGeometry height="32" width="120" x="65" y="308" as="geometry" />
        </mxCell>
        <mxCell id="23" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#166534;strokeColor=#4ade80;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="130" width="780" x="70" y="350" as="geometry" />
        </mxCell>
        <mxCell id="24" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#3b82f6;strokeColor=#60a5fa;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value=".java" vertex="1">
          <mxGeometry height="40" width="80" x="90" y="365" as="geometry" />
        </mxCell>
        <mxCell id="25" edge="1" parent="1" source="24" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#fbbf24;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="26" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="180" y="385" as="sourcePoint" />
            <mxPoint x="230" y="385" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="26" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#8b5cf6;strokeColor=#a78bfa;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value=".class" vertex="1">
          <mxGeometry height="40" width="80" x="230" y="365" as="geometry" />
        </mxCell>
        <mxCell id="27" parent="1" style="text;html=1;strokeColor=none;fillColor=#fbbf24;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#1e293b;rounded=1;" value="javac" vertex="1">
          <mxGeometry height="18" width="45" x="180" y="345" as="geometry" />
        </mxCell>
        <mxCell id="28" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#86efac;" value="编译" vertex="1">
          <mxGeometry height="18" width="50" x="175" y="405" as="geometry" />
        </mxCell>
        <mxCell id="29" edge="1" parent="1" source="26" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#fbbf24;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="30" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="320" y="385" as="sourcePoint" />
            <mxPoint x="370" y="385" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="30" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f59e0b;strokeColor=#fbbf24;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="解释器" vertex="1">
          <mxGeometry height="40" width="80" x="370" y="365" as="geometry" />
        </mxCell>
        <mxCell id="31" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=11;fontColor=#86efac;" value="逐行" vertex="1">
          <mxGeometry height="18" width="40" x="320" y="405" as="geometry" />
        </mxCell>
        <mxCell id="32" edge="1" parent="1" source="30" style="endArrow=classic;html=1;strokeWidth=3;strokeColor=#fbbf24;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" target="33" value="">
          <mxGeometry height="50" relative="1" width="50" as="geometry">
            <mxPoint x="460" y="385" as="sourcePoint" />
            <mxPoint x="510" y="385" as="targetPoint" />
          </mxGeometry>
        </mxCell>
        <mxCell id="33" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#22c55e;strokeColor=#4ade80;strokeWidth=2;fontSize=14;fontStyle=1;fontColor=#ffffff;" value="执行" vertex="1">
          <mxGeometry height="40" width="70" x="510" y="365" as="geometry" />
        </mxCell>
        <mxCell id="34" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#7c2d12;strokeColor=#f97316;strokeWidth=2;dashed=1;" value="" vertex="1">
          <mxGeometry height="60" width="225" x="610" y="355" as="geometry" />
        </mxCell>
        <mxCell id="35" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JIT" vertex="1">
          <mxGeometry height="22" width="40" x="625" y="365" as="geometry" />
        </mxCell>
        <mxCell id="36" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="热点代码 → 机器码缓存" vertex="1">
          <mxGeometry height="24" width="160" x="670" y="363" as="geometry" />
        </mxCell>
        <mxCell id="37" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=11;fontColor=#fdba74;" value="🔥 性能优化" vertex="1">
          <mxGeometry height="20" width="90" x="625" y="388" as="geometry" />
        </mxCell>
        <mxCell id="38" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#065f46;strokeColor=#34d399;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="40" width="400" x="90" y="430" as="geometry" />
        </mxCell>
        <mxCell id="39" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;fontSize=16;fontColor=#4ade80;" value="→" vertex="1">
          <mxGeometry height="24" width="30" x="100" y="438" as="geometry" />
        </mxCell>
        <mxCell id="40" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#bbf7d0;" value="Java 是 &quot;编译与解释并存&quot; 的语言" vertex="1">
          <mxGeometry height="24" width="280" x="130" y="438" as="geometry" />
        </mxCell>
        <mxCell id="41" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#7c2d12;strokeColor=#f97316;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="180" width="400" x="50" y="515" as="geometry" />
        </mxCell>
        <mxCell id="42" parent="1" style="text;html=1;strokeColor=none;fillColor=#f97316;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🚀 JIT vs AOT" vertex="1">
          <mxGeometry height="32" width="130" x="65" y="528" as="geometry" />
        </mxCell>
        <mxCell id="43" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#9a3412;strokeColor=#fb923c;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="110" width="170" x="70" y="570" as="geometry" />
        </mxCell>
        <mxCell id="44" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JIT" vertex="1">
          <mxGeometry height="26" width="50" x="85" y="580" as="geometry" />
        </mxCell>
        <mxCell id="45" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="• 启动慢" vertex="1">
          <mxGeometry height="20" width="80" x="85" y="610" as="geometry" />
        </mxCell>
        <mxCell id="46" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="• 峰值性能高" vertex="1">
          <mxGeometry height="20" width="100" x="85" y="630" as="geometry" />
        </mxCell>
        <mxCell id="47" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="• 支持动态特性" vertex="1">
          <mxGeometry height="20" width="120" x="85" y="650" as="geometry" />
        </mxCell>
        <mxCell id="48" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#9a3412;strokeColor=#fb923c;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="110" width="170" x="260" y="570" as="geometry" />
        </mxCell>
        <mxCell id="49" parent="1" style="text;html=1;strokeColor=none;fillColor=#8b5cf6;align=center;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#ffffff;rounded=1;" value="AOT" vertex="1">
          <mxGeometry height="26" width="50" x="275" y="580" as="geometry" />
        </mxCell>
        <mxCell id="50" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="• 启动快" vertex="1">
          <mxGeometry height="20" width="80" x="275" y="610" as="geometry" />
        </mxCell>
        <mxCell id="51" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="• 内存小" vertex="1">
          <mxGeometry height="20" width="80" x="275" y="630" as="geometry" />
        </mxCell>
        <mxCell id="52" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#fed7aa;" value="• 动态特性受限" vertex="1">
          <mxGeometry height="20" width="120" x="275" y="650" as="geometry" />
        </mxCell>
        <mxCell id="53" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1e3a5f;strokeColor=#3b82f6;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="180" width="400" x="470" y="515" as="geometry" />
        </mxCell>
        <mxCell id="54" parent="1" style="text;html=1;strokeColor=none;fillColor=#3b82f6;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="📦 JDK 选择" vertex="1">
          <mxGeometry height="32" width="120" x="485" y="528" as="geometry" />
        </mxCell>
        <mxCell id="55" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1e40af;strokeColor=#60a5fa;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="110" width="360" x="490" y="570" as="geometry" />
        </mxCell>
        <mxCell id="56" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="推荐发行版" vertex="1">
          <mxGeometry height="22" width="85" x="505" y="582" as="geometry" />
        </mxCell>
        <mxCell id="57" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=13;fontColor=#bfdbfe;" value="OpenJDK 发行版" vertex="1">
          <mxGeometry height="24" width="140" x="600" y="580" as="geometry" />
        </mxCell>
        <mxCell id="58" parent="1" style="text;html=1;strokeColor=none;fillColor=#6366f1;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Temurin" vertex="1">
          <mxGeometry height="22" width="70" x="520" y="612" as="geometry" />
        </mxCell>
        <mxCell id="59" parent="1" style="text;html=1;strokeColor=none;fillColor=#f59e0b;align=center;verticalAlign=middle;fontSize=11;fontStyle=1;fontColor=#ffffff;rounded=1;" value="Corretto" vertex="1">
          <mxGeometry height="22" width="70" x="600" y="612" as="geometry" />
        </mxCell>
        <mxCell id="60" parent="1" style="text;html=1;strokeColor=none;fillColor=#22c55e;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="推荐版本" vertex="1">
          <mxGeometry height="22" width="75" x="505" y="645" as="geometry" />
        </mxCell>
        <mxCell id="61" parent="1" style="text;html=1;strokeColor=none;fillColor=#8b5cf6;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 17" vertex="1">
          <mxGeometry height="22" width="65" x="595" y="645" as="geometry" />
        </mxCell>
        <mxCell id="62" parent="1" style="text;html=1;strokeColor=none;fillColor=#ec4899;align=center;verticalAlign=middle;fontSize=12;fontStyle=1;fontColor=#ffffff;rounded=1;" value="JDK 21" vertex="1">
          <mxGeometry height="22" width="65" x="670" y="645" as="geometry" />
        </mxCell>
        <mxCell id="63" parent="1" style="text;html=1;strokeColor=none;fillColor=#10b981;align=center;verticalAlign=middle;fontSize=10;fontStyle=1;fontColor=#ffffff;rounded=1;" value="LTS" vertex="1">
          <mxGeometry height="18" width="35" x="745" y="648" as="geometry" />
        </mxCell>
        <mxCell id="64" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#1f2937;strokeColor=#6b7280;strokeWidth=2;" value="" vertex="1">
          <mxGeometry height="145" width="820" x="50" y="715" as="geometry" />
        </mxCell>
        <mxCell id="65" parent="1" style="text;html=1;strokeColor=none;fillColor=#6b7280;align=center;verticalAlign=middle;fontSize=16;fontStyle=1;fontColor=#ffffff;rounded=1;" value="💡 使用场景建议" vertex="1">
          <mxGeometry height="32" width="160" x="65" y="728" as="geometry" />
        </mxCell>
        <mxCell id="66" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#374151;strokeColor=#9ca3af;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="75" width="380" x="70" y="770" as="geometry" />
        </mxCell>
        <mxCell id="67" parent="1" style="text;html=1;strokeColor=none;fillColor=#ef4444;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="🖥️ 长期运行服务" vertex="1">
          <mxGeometry height="26" width="140" x="85" y="782" as="geometry" />
        </mxCell>
        <mxCell id="68" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#fca5a5;" value="→ 使用 JIT" vertex="1">
          <mxGeometry height="26" width="100" x="240" y="782" as="geometry" />
        </mxCell>
        <mxCell id="69" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#d1d5db;" value="峰值性能高,适合 Web 服务、微服务" vertex="1">
          <mxGeometry height="22" width="280" x="85" y="812" as="geometry" />
        </mxCell>
        <mxCell id="70" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#374151;strokeColor=#9ca3af;strokeWidth=1;" value="" vertex="1">
          <mxGeometry height="75" width="380" x="470" y="770" as="geometry" />
        </mxCell>
        <mxCell id="71" parent="1" style="text;html=1;strokeColor=none;fillColor=#8b5cf6;align=center;verticalAlign=middle;fontSize=13;fontStyle=1;fontColor=#ffffff;rounded=1;" value="☁️ 云原生/Serverless" vertex="1">
          <mxGeometry height="26" width="165" x="485" y="782" as="geometry" />
        </mxCell>
        <mxCell id="72" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=14;fontStyle=1;fontColor=#c4b5fd;" value="→ 使用 AOT" vertex="1">
          <mxGeometry height="26" width="100" x="665" y="782" as="geometry" />
        </mxCell>
        <mxCell id="73" parent="1" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;fontSize=12;fontColor=#d1d5db;" value="启动快、内存小,适合容器化部署" vertex="1">
          <mxGeometry height="22" width="260" x="485" y="812" as="geometry" />
        </mxCell>
      </root>
    </mxGraphModel>
  </diagram>
</mxfile>